40 likes | 43 Views
Program to calculate product of odd numbers b/w 1 and 15. #include <stdio.h> main() { int prod = 1, x; for(x = 1; x <= 15; x += 2) prod *= x; printf(“Product is %d.<br>”, prod); }. /* Program to count letter grades */. #include <stdio.h> int main() {
E N D
Program to calculate product of odd numbers b/w 1 and 15 #include <stdio.h> main() { int prod = 1, x; for(x = 1; x <= 15; x += 2) prod *= x; printf(“Product is %d.\n”, prod); }
/* Program to count letter grades */ #include <stdio.h> 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’ ) {
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;
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); }