Advertisement
hpolzer

Square Numbers

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