Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- main ()
- {
- int x, n, gesamt=0;
- printf("\n\tADD THE ODDS\n");
- printf("\nDieses Programm rechnet alle ungeraden Zahlen bis n zusammen\n");
- printf("\nBitte Wert für n eingeben: \n");
- scanf("%i", &n);
- for (x=0; x<=n; x=x+1)
- {
- if ((x%2))
- gesamt = gesamt + x;
- else
- continue;
- }
- printf("\nDie Summe der ungeraden Zahlen bis n beträgt %i\n", gesamt);
- }
Advertisement
Add Comment
Please, Sign In to add comment