/*there is a fractional sequence: 2/1,3/2,5/3,8/5,13/8,21/13. Find the sum of the first 20 items of this series. */#include<stdio.h>intMainvoid){ intn,t,num= -; floatA=2, b=1, s=0; for(n=1; n<=num;n++) {s=s+a/b; T=A; A=a+b; b=t;/*This part is the key to the program*/} printf ("and for%9.6f\n", s); }
/*Print out all the "daffodils", the so-called "daffodils number" refers to a three-digit number, whose numbers are cubic and equal to the number itself. For example: 153 is a "narcissus number", because the 153=1 three times the square +5 of the three +3-time Square*/#include<stdio.h>intMainvoid){ intNUM,GW,SW,BW; Num=0, gw=0, sw=0, bw=0; for(num= -; num<=999; num++) {GW=num%Ten; SW=num/Ten%Ten; Bw=num/ -; if(NUM!=GW*GW*GW+SW*SW*SW+BW*BW*BW)Continue; printf ("The number of daffodils are:%d\n", num); } }
/*give a positive integer with no more than 5 digits, ask: ask for a number of digits and print out the numbers in reverse order*/#include<stdio.h>intMainvoid){ intnum,i,j,x; Num=0, i=0, x=0; printf ("Please enter a positive integer no higher than five bits: \ n"); scanf ("%d",&num); while(num!=0) {num=num/Ten; I++; } printf ("This number is%d digits \ n", i); for(j=0; j<i;j++) {num=num/Ten; for(x=0; x!=0; x + +) {x=num%Ten; } printf ("%d", x); } }
815 C Language Jobs