Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Quadratzahlen als Summe der ungeraden Zahlen in ANSI C,
- Eingabe der Obergrenze in der Kommandozeile,
- Henning Polzer, 25. Januar 2020,
- Uebersetzen mit gcc -ansi -pedantic -O3 -o quad quad.c,
- i = Schleifenzaehler, og = Obergrenze, s = Summe.
- */
- #include <stdio.h>
- #include <stdlib.h>
- int main (int argc,char *argv[])
- {
- unsigned i=0,og=(argc==2)?(atoi(argv[1])):(og=0),s=0;
- while (((s+=(i+=2)-1)<=og)?printf("%d\n",s):0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement