Steven
2012-11-28 12:44:59 UTC
#include
#include
#include
int getRange(int a, int b){
int grade;
do {
printf("Please enter a number inclusively between %d and %d.\n", a, b);
scanf("%d",&grade);
if (grade < a || grade > b) {
printf("This number is not between %d and %d.\n", a, b);}
}while (grade < a || grade > b);
printf("%d was accepted\n", grade);
return grade;
}
int getGradeTotal(int a, int b, int rep) {
int ttl;
while (rep > 0) {
ttl += getRange(a , b);
rep --;}
printf("The total is %d.\n",ttl);
return ttl;}
int main() {
int a = 0, b = 100, c = 110, ttl = 0, rept = 2, repp = 5, sal, test;
sal = getRange(a , b);
printf("%d\n",sal);
test = getGradeTotal(a, b, repp);
printf("%d\n",test);
scanf("%d",&sal);
return 0;
}
The scanf at the end is because dev C++ program window thingy will close immediately after running, so I'm unable to accually view the information it gives back. (But with the scanf there, I can read it all while it waits for input =3)
Sorry for the terrible spacing, Yahoo answers normally murders it.