Pages

Showing posts with label c example. Show all posts
Showing posts with label c example. Show all posts

to Generate Fibonacci Series

Tuesday, 9 July 2013
#include<stdio.h>
#include<conio.h>

void main()
{
    int a,b,c;
    int i=1;
    a=0;
    b=1;
   
    printf(“Fibonacci Series”);
    printf(“%d\n”, a);
    printf(“%d\n”, b);

    while(i<=10)
    {
        c=a+b;
        printf(“%d”, c);
        a=b;
        b=c;
        i++;
    }
    getch();
}
Read more ...

To Find Armstrong Number (Series)

Monday, 8 July 2013
//C Program to Find All Armstrong Number between 1 to 1000.

#include<stdio.h>
#include<conio.h>

void main()
{
  int no,r,i;
  int sum=0;
  clrscr();
  printf("\n\n***The Armstrong No. Series Between 1 and 1000 are:***  ");
 
  for(i=1;i<=1000;i++)
  {
       sum=0;
       no=i;
       while(no!=0)
       {
            r=no%10;
            no=no/10;
            sum=sum+(r*r*r);
       }
       if(sum==i)
        printf("\n%d",i);
   }
   getch();
}
Read more ...