Hi..can some1 correct my code?what did i mistaks here?i didn't get...?please tell.. :(
code(1)..
#include <iostream.h>
main()
{
int number;
int digit;
cout<< "please Enter a 4 digit integer:";
cin>>number;
digit=number% 10;
cout<< "the digit is:"<< digit << '\n';
number=number/10;
digit=number%10;
cout<<"the digit is:"<< digit <<'\n';
number=numbre/10;
digit=number%10;
cout<<"the digit is:"<< digit <<'\n';
number=number/10;
digit=number%10;
cout<<"the digit is:"<< digit;
}
code(2)...
#include <iostream.h>
main()
{
int age1,age2,age3,age4,age5,age6,age7,age8,age9,age10;
int totalAge;
int averageAge;
cout <<"please enter the age of student1:" ;
cin >>age1;
cout <<"please enter the age of student2:" ;
cin >>age2;
cout <<"please enter the age of student3:" ;
cin >>age3;
cout <<"please enter the age of student4:" ;
cin >>age4;
cout <<"please enter the age of student5:" ;
cin >>age5;
cout <<"please enter the age of student6:" ;
cin >>age6;
cout <<"please enter the age of student7:" ;
cin >>age7;
cout <<"please enter the age of student8:" ;
cin >>age8;
cout <<"please enter the age of student9:" ;
cin >>age9;
cout <<"please enter the age of student10:" ;
cin >>age10;
Totalage = age1+ age2+ age3+ age4+ age5+ age6+ age6+ age7+ age8+ age9+ age10;
AverageAge = Totalage /10;
cout <<"the Average Age of the class is:"
<< AverageAge;
}
Regardz.
They both should work. Some problems : main should be int, and therefore should return something (0 preferably). Also, you should probably be using loops and arrays. For example