Skip to main content

Posts

Showing posts from February, 2016

FIBONACCI SEQUENCE

Q1 :  Write a C program to print " Fibonacci Sequence " as an output? #include<conio.h>     #include<stdio.h>      void main()                 {                                  //fibonacci series        int a=0,b=1,i,c=0;       clrscr();                       for(i=1;i<=10;i++)       {                                 printf("%d\t",c);          a=b;                           b=c;                           c=a+b;                       }                                 getch();                      }                                  *********************************************************************************** Sample Output:

SWAPPING OF VALUES C CODE

Q1 : Write a C program to " interchange" values without using third                     variable?  #include<conio.h>                       #include<stdio.h>                        void main()                                  {                                                   clrscr();                                        //interchange number                  int a=4;                                        int b=5;                                        clrscr();                                        printf("\na=%d",a);                       printf("\nb=%d",b);                       b=a+b;                                         a=b-a;                                          b=b-a;                                          printf("\nAfter interchanging ");    printf("\na=%d",a);                       printf("\nb=%d ",b);                      getch();