Fotografiona

aufg17.c

Sep 18th, 2012
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. main ()
  3. {
  4. int x, n, gesamt=0;
  5. printf("\n\tADD THE ODDS\n");
  6. printf("\nDieses Programm rechnet alle ungeraden Zahlen bis n zusammen\n");
  7. printf("\nBitte Wert für n eingeben: \n");
  8. scanf("%i", &n);
  9. for (x=0; x<=n; x=x+1)
  10. {
  11. if ((x%2))
  12. gesamt = gesamt + x;
  13. else
  14. continue;
  15. }
  16. printf("\nDie Summe der ungeraden Zahlen bis n beträgt %i\n", gesamt);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment