Presentation is loading. Please wait.

Presentation is loading. Please wait.

Program to calculate product of odd numbers b/w 1 and 15 #include main() { int prod = 1, x; for(x = 1; x <= 15; x += 2) prod *= x; printf(“Product is %d.\n”,

Similar presentations


Presentation on theme: "Program to calculate product of odd numbers b/w 1 and 15 #include main() { int prod = 1, x; for(x = 1; x <= 15; x += 2) prod *= x; printf(“Product is %d.\n”,"— Presentation transcript:

1 Program to calculate product of odd numbers b/w 1 and 15 #include main() { int prod = 1, x; for(x = 1; x <= 15; x += 2) prod *= x; printf(“Product is %d.\n”, prod); }

2 /* Program to count letter grades */ #include int main() { int grade; int aCount = 0, bCount = 0, cCount = 0, dCount = 0, fCount = 0; printf(“Enter the letter grades.\n”); printf(“Enter ‘x’ to end input.\n”); while ( ( grade = getchar() ) != ‘x’ ) {

3 switch (grade) { case ‘A’: case ‘a’: ++aCount; break; case ‘B’: case ‘b’: ++bCount; break; case ‘C’: case ‘c’: ++cCount; break; case ‘D’: case ‘d’: ++dCount; break; case ‘F’: case ‘f’: ++fCount; break;

4 case ‘\n’: case ‘’ : break; default: /* other characters */ printf(“Invalid input.\n”); printf(“Enter new grade.\n”); break; } printf(“Total grades entered \n”); printf(“A : %d \n”, aCount); printf(“B : %d \n”, bCount); printf(“C : %d \n”, cCount); printf(“D : %d \n”, dCount); printf(“F : %d \n”, fCount); }


Download ppt "Program to calculate product of odd numbers b/w 1 and 15 #include main() { int prod = 1, x; for(x = 1; x <= 15; x += 2) prod *= x; printf(“Product is %d.\n”,"

Similar presentations


Ads by Google