1 / 4

Program to calculate product of odd numbers b/w 1 and 15

Program to calculate product of odd numbers b/w 1 and 15. #include &lt;stdio.h&gt; main() { int prod = 1, x; for(x = 1; x &lt;= 15; x += 2) prod *= x; printf(“Product is %d.<br>”, prod); }. /* Program to count letter grades */. #include &lt;stdio.h&gt; int main() {

bernardt
Download Presentation

Program to calculate product of odd numbers b/w 1 and 15

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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); }

  2. /* 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’ ) {

  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); }

More Related