10.20.2011

Number seriess


/*program to print number series as
1 4 9 25....100 */
#include<stdio.h>
#include<conio.h>
int main()
{
 int x=1,y=2,z,s;
 for(; x<=8; )
 {
   s=x*x;
   printf(" %d",s);
   z=x+y;
   x=y;
   y=z;
 }
 getch();
 return 0;
}

Output:1 4 9 25 64

/*program of print following number series
-10 -8 -6 -4 -2 0 2 4 6 8 10 */
#include<stdio.h>
#include<conio.h>
int main()
{
 int x;
 for(x=-10; x<=10;x=x+2)
    printf(" %d",x);
 getch();
 return 0;
}
Output:  -10 -8 -6 -4 -2 0 2 4 6 8 10

No comments:

Post a Comment