Pages

Sunday 13 June 2021

Programs in turboc3 : Files

File Handling in C
File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our data in Secondary memory (Hard disk). All files related function are available in stdio.h header file.

How to achieve File Handling in C
For achieving file handling in C we need to follow following steps
•Naming a file
•Opening a file
•Reading data from file
•Writing data into file
•Closing a file

Functions use in File Handling in C
S.No Function Operation
1 fopen() To create a file
2 fclose() To close an existing file
3 getc() Read a character from a file
4 putc() Write a character in file
5 fprintf() To write set of data in file
6 fscanf() To read set of data from file.
5 getw() To read an integer from a file
6 putw() To write an integer in file

Defining and Opening a File
Data structure of file is defined as FILE in the standard I/O function. So all files should be declared as type FILE.
Before opening any file we need to specify for which purpose we open file, for example file open for write or read purpose.

Syntax
FILE *fp;
fp=fopen("filename", "mode");
Here fp declare a variable as a pointer to the data type FILE.

Closing a File
A file must be close after completion of all operation related to file. For closing file we need fclose() function.
Syntax
fclose(Filepointer);

File Opening mode
Sno Mode Meaning Purpose
1 r Reading Open the file for reading only.
2 w Writing Open the file for writing only.
3 a Appending Open the file for appending (or adding) data to it.
4 r+ Reading + Writing New data is written at the beginning override existing data.
5 w+ Writing + Reading Override existing data.
6 a+ Reading + Appending To new data is appended at the end of file.

Input/Output Operation on files
To perform Input/Output Operation on files we need below functions.
S.No Function Operation Syntax
1 getc() Read a character from a file getc( fp)
2 putc() Write a character in file putc(c, fp)
3 fprintf() To write set of data in file fprintf(fp, "control string", list)
4 fscanf() To read set of data from file. fscanf(fp, "control string", list)
5 getw() To read an integer from a file. getw(fp)
6 putw() To write an integer in file. putw(integer, fp)


/* Program to read data  from keyboard write it to a file named as INPUT,again read the same data from file and display it on the screen */

#include<stdio.h>
#include<conio.h>
void main()
{
   FILE *f1;
   char c;
   clrscr();
   printf("DATA INPUT\n\n");
   f1 = fopen("INPUT", "w");
   while((c=getchar())!=EOF)
   putc(c,f1);
   fclose(f1);
   printf("DATA OUTPUT\n\n");
   f1 = fopen("INPUT", "r");
   while((c=getc(f1))!=EOF)
   printf("%c",c);
   fclose(f1);
   getch();
}

OUTPUT:
DATA INPUT
this is my first program 
ctrl+z
DATA OUTPUT
this is my first program 


/*  Program to read set of integers into a file name as DATA,and then write all odd numbers to a file named as ODD and all even numbers to a file named as EVEN */ 

#include <stdio.h>
#include <conio.h>
void main()
{
   FILE *f1,*f2,*f3;
   int no,i;
   clrscr();
   printf("CONTENT OF DATA FILE\n\n");
   f1 = fopen("DATA", "w");
   for(i=1;i<=5;i++)
   {
    scanf("%d",&no);
    if(no == -1)
     break;
    putw(no,f1);
   }
   fclose(f1);
   f1=fopen("DATA","r");
   f2=fopen("ODD","w");
   f3=fopen("EVEN","w");
      while((no=getw(f1))!=EOF)
      {
       if(no%2 == 0)
putw(no,f3);
       else
putw(no,f2);
      }
   fclose(f1);
   fclose(f2);
   fclose(f3);
   f2=fopen("ODD","r");
   f3=fopen("EVEN","r");
   printf("\n\nCONTENT OF ODD FILE");
   while((no=getw(f2))!=EOF)
   printf("%4d",no);
   printf("\n\nCONTENT OF EVEN FILE");
   while((no=getw(f3))!=EOF)
   printf("%4d",no);
   fclose(f2);
   fclose(f3);
  getch();
}

output:


/*  Program to read the student data from file named by std and display the file using fprintf and fscanf statements */ 

#include <stdio.h>
void main()
{
   FILE *fp;
   int rno,i,m1,m2,val;
   char name[20],filename[10];
   clrscr();
   printf("INPUT FILE NAME\n\n");
   scanf("%s",filename);
   fp = fopen("filename", "w");
   printf("INPUT THE STUDENT DATA\n");
   printf("name --- rollno  ---  m1 ---- m2   \n");
   for(i=1;i<=3;i++)
   {
    fscanf(stdin,"%s %d %d %d", name,&rno,&m1,&m2);
    fprintf(fp,"%s %d %d %d", name,rno,m1,m2);
   }
   fclose(fp);
   fprintf(stdin,"\n\n");
   fp=fopen("filename","r");
   printf("name --- rollno  ---  m1 ---- m2 --- val\n");
   for(i=1;i<=3;i++)
   {
    fscanf(fp,"%s %d %d %d", name,&rno,&m1,&m2);
    val=m1 + m2;
    printf("\n");
    fprintf(stdout,"%s %d %d %d %d", name,rno,m1,m2,val);
   }
   fclose(fp);
getch();
}

Thursday 27 May 2021

Programs in turboc3: Functions - Types of Functions

Syntax:
return type      function name (argument list)
                       {
                         Body of the loop
                       }
Characteristics  of a function :
1.Function declaration or proto type
2.Calling function sum();
3.Called function can be divided into 4 categories:
      (i) Function with no return and no argument
     (ii) Function with no return and with argument
     (iii) Function with return and with no argument
     (iv) Function with return and with argument

Note:
1. The parameters which are used under calling functions are called Actual parameters.
2. The parameters which are used under called functions are called Dummy parameters.

/*Function with no return and no argument*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
void sum(void);   /*Function Declaration or Proto Type*/
void main()
{
clrscr();
sum();                     /*Calling Function*/
getch();
}

Void sum(void)         /*called function*/
{
   int a,b,c;
   printf(“enter a,b values:”);
   scanf(“%d%d”,&a,&b);
   c=a+b;
   printf(“sum is %d”,c);
}
 
output:

/*Example2:Function with no return and no argument*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
void mul(void);
 /*Function Declaration or Proto Type*/
void main()
{
clrscr();
mul();       /*calling function*/
getch();
}

void mul(void)     /*called function*/
{
   int a,b,c;
   printf(“enter a,b values:”);
   scanf(“%d%d”,&a,&b);
   c=a*b;
   printf(“multiplication is %d”,c);
}

output:
/* Function with no return and with argument*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
void sum(int,int);        
 /*Function Declaration or Proto Type*/
void main()
{
   int a,b;
   clrscr();
   printf(“enter a,b values:”);
   scanf(“%d%d”,&a,&b);
   sum(a,b);    /*calling function*/            // actual parameters
   getch();
}

void sum(int p,intq)      *called function*/       // dummy parameters
{
   int r;
   r=p+q;
   printf(“sum is %d”,r);
}

output:

/* Example 2:Function with no return and with argument*/ 
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
void mul(int,int);
  /*Function Declaration or Proto Type*/
void main()
{
   int a,b;
   clrscr();
   printf(“enter a,b values:”);
   scanf(“%d%d “,&a,&b);
   mul(a,b);       /*calling function*/   
   getch();
}

void mul(int p,intq)    /*called function*/
{
   int r; 
   r=p*q;
   printf(“multiplication is %d”,r);
}

output:

/* Function with return and with no argument*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
int sum(void);
  /*Function Declaration or Proto Type*/
void main()
{
   int c;
   clrscr();
   c=sum();    /*calling function*/
   printf(“sum is %d”,c);
   getch();
}
 int sum(void)   /* called function*/
 {
    int p,q,r;
    printf(“enter p,q values:”);
    scanf(“%d%d”,&p,&q);
    r=p+q;
    return r;
 }

output:
/* Example2:Function with return and with no argument*/ 
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
int mul(void);
  /*Function Declaration or Proto Type*/
void main()
 {
    int c;
    clrscr();
    c=mul();    /*calling function*/
    printf(“multiplication is %d”,c);
    getch();
 }
   
int mul(void)   /*called function*/
   {
      int p,q,r;
      printf(“enter p,q values”);
      scanf(“%d%d”,&p,&q);
      r=p*q;
      return r;
    }
 output:

/*Function with return and with argument*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<string.h>
int sum(int,int);      
  /*Function Declaration or Proto Type*/
void main()
{
   int a,b,c;
   clrscr();
   printf(“enter a,b values”);
   scanf(“%d%d”,&a,&b);
   c=sum(a,b);        /*calling function*/      // actual parameters
   printf(“sum is %d “,c);
   getch();
}
int sum (int p,int q)    /*called function*/         // dummy parameters
{
   int z;
   z=p+q;
   return z;


output:
/*Example 2:Function with return and with argument*/ 
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
int mul(int,int);
  /*Function Declaration or Proto Type*/
void main()
{
   int a,b,c;
   clrscr();
   printf(“enter a,b values”);
   scanf(“%d%d”,&a,&b);
   c=mul(a,b);
   printf(“multiplication is %d “,c);
   getch();
}
int mul(int p,int q)
{
    int z;
    z=p+q;
    return z;
}
 
output:

Tuesday 25 May 2021

Programs in turboc3: Recursions - factorial,multiplication,power,GCD,Fibonacci,Towers of hanoi

/*Factorial of a number 'n' i.e below 8 using recursion  */

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
int fact(int n);  /* function declaration */
void main()
{
  int n,f;
  clrscr();
  printf(“enter any value:”);
  scanf(“%d”,&n);
  f=fact(n);          /* calling function */
  printf(“\n factorial of %d is %d”,n,f);
  getch();
}

int fact (int n)    /* called function */
{
  int f;
  if(n==1)
  return 1;
  f=n*fact(n-1);
  return (f);
}

Output:


/*Factorial of a number 'n' i.e above 8 using recursion  */
#include<stdio.h>
#include<conio.h>
long factr(int); /* function declaration */
void main()
{
 long fact;
 int n;
 clrscr();
 printf("enter any value:\n");
 scanf("%d",&n);
 fact=factr(n);    /* calling function */
 printf("factorial of %d = %ld",n,fact);
 getch();
 }

 long factr(n)   /* called function */
  {
  long fac;
  if(n==1)
  return 1;
  fac=n*factr(n-1);
  return (fac);
  }


/*Multiplication of two numbers using recursion*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include <math.h>
int mult (int,int)    /* function declaration */
void main()
{
  int a,b,c;
  clrscr();
  printf(“enter any two numbers:”);
  scanf(“%d%d”,&a,&b);
  c=mult(a,b);     /* calling function */
  printf(“multiplication of %d and %d is %d”,a,b,c);
  getch();
}

int mult (int a,int b)    /* called function */
{
   if(b==1)
   return a;
   c=b+mult(a,b-1);
   return (c);
}

Output: 

/*Power of two numbers using recursion*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
int a,b,c;
int pow(int,int);
void main()
{
  int c;
clrscr();
printf(“enter any two numbers:”);
scanf(“%d%d,&a,&b);
c=pow(a,b);
printf(“\n power of %d and %d is %d”,a,b,c);
getch();
}

int pow (int a,int b)
{
   int c;
   if(b==0)
   return 1;
   c=a*pow(a,b-1);
   return (c);
}

Output:

/*GCD of two numbers using recursion*/

#include<stdio.h>
#include<conio.h>
int gcd(int,int); /* function declaration */
void main()
{
 int a,b,c;
 clrscr();
 printf("\n enter any two values:\n");
 scanf("%d%d",&a,&b);
 c=gcd(a,b);   /* calling function */
 printf("GCD of %d and %d = %d",a,b,c);
 getch();
}

 int gcd(int m,int n)    /* called function  */
 { int x;
  if(n==0)
  return m;
  if(n>m)
   return (gcd(n,m));
  else
   x=m%n;
  return(gcd(n,x));
 }

Output:

/* Fabinacci series using recursion*/

#include<stdio.h>
#include<conio.h>
int n,fib;   /* global variable */
int fibon(int); /* function declaration */
void main()
{
 int i;
 clrscr();
 printf("enter any value:\n");
 scanf("%d",&n);
 printf("\n Fabinacci series of %d: \n",n);
 for(i=0;i<n;i++)
 {
 fib=fibon(i);     /* calling function */
 printf("%d\t",fib);
 }
 getch();
}

 int fibon(n)  /* called function */
 {
  int a,b;
  if(n<=1)
  return n;
  a=fibon(n-1);
  b=fibon(n-2);
  return (a+b);
 }

Output:


/* Towers of Hanoi using recursion */
#include<stdio.h>
#include<conio.h>
void hanoi(int,char,char,char); /* function declaration */
void main()
{
 int n;
 clrscr();
 printf("\n Enter no. of disks to be moved:\n");
 scanf("%d",&n);
 hanoi(n,'X','Z','Y');
 getch();
}

 void hanoi(int n,char initial,char final,char temp)
 {
  if(n==1)
  {
  printf("move disk 1 from needle  %c to %c\n",initial,final);
  return;
  }
 hanoi(n-1,initial,temp,final);
 printf("move disk %d from needle  %c to %c\n",n,initial,final);
 hanoi(n-1,temp,final,initial);
 }

output:

Friday 14 May 2021

Programs in turboc3 : Strong ,Armstrong,Perfect ,Magic, Palindrome Number including min and max ranges &Reverse,Fibonacci series

/ * Strong Number * /

Definition :A number is called strong number if sum of it's factorials of it's digits is equal to number itself. 

Example : 145

           = 1! + 4! + 5! 

           = 1+24+120 

           =145

Program :
 #include<stdio.h>
 #include<conio.h>
  void main( ) 
  {
      int n, i, f, r, sum=0, tmp;
      clrscr( ) ;
      printf(" Enter any number ") ;
      scanf("%d", &n) ;
       tmp=n;
       while(n) or while (n! =0) 
        {
            i=1 ;
            f=1 ;
            r=n%10 ;
             while (i<=r) 
              {
                  f=f * i ;
                   i ++ ;
              }
                sum=sum+f ;
                   n=n/10 ;
         }
            if(sum==tmp) 
              printf("\n%d is Strong number ", tmp) ;
            else
               printf(“\n%d is not a strong number", tmp) ;
     getch ( );
   }


/ * Strong number range in between min &max */ 

#include<stdio.h>
#include<conio.h>
 void main( )
 {
    long int min, max, n, i, f, r, sum,tmp;
    clrscr( ) ;
    printf(" \nEnter minimum number ") ;
    scanf("%ld",&min) ;
    printf("\n Enter maximum number ") ;
    scanf("%ld",&max) ;
    printf("\nStrong numbers are:") ;
      for(n=min;n<=max;n++)
{
tmp=n;
sum=0;
while (tmp)
   {
     i=1 ;
     f=1 ;
     r=tmp%10 ;
     while (i<=r)
       {
  f=f * i ;
   i ++ ;
       }
    sum=sum+f ;
    tmp=tmp/10 ;
  }
if(sum==n)
  printf("\n%ld is Strong number", n);
       }
       getch ( );
   }

Output:

             1        2      145      40585


/*   Armstrong Number */

Definition:- Those number whose sum of its digits to power of number of its digits is equal to that number is known as Armstrong number.

      For example : 153,  370, 371

      Total  Digits in 153 is  3

      And 13 +53+33 =1+125+27=153

      For example : 1634

      Total Digits in 1634 is 4

       And 14+64+34+44=1+1296+81+256 =1634

Program :- 
    #include<stdio.h>
    #include<conio.h>
    void main( )
    {
       int  n,r, sum=0,tmp ;
       clrscr( ) ;
       printf(“Enter any number:”) ;
       scanf(“%d”,&n) ;
       tmp=n ;
       while(n)
        {
          r=n%10 ;
          n=n/10 ;
         sum=sum+(r*r*r*) ;
        }
      if(sum==tmp) 
        printf(“\n%d  is an Armstrong number”,tmp) ;
      else
         printf(“\n%d is not an Armstrong number”,tmp) ;
     getch( ) ;
   }


/* Min & Max range of an Armstrong number */
     #include<stdio.h>
     #include<conio.h>
     void main( )
     {
       int min,max,n,sum=0,r,tmp ;
       clrscr( ) ;
       printf(“\nEnter min number:”) ;
       scanf(“%d”,&min) ;
       printf(“\nEnter max number:”) ;
       scanf(“%d”,&max) ;
       printf(“\n Armstrong number is the given range :”) ;
       for( n=min ; n<=max ; n++)
        {
          tmp=n ; 
          sum=0 ;
          while(tmp!=0)
           { 
             r=tmp%10 ;
             tmp=tmp/10 ;
             sum=sum+(r*r*r) ;
           }
          if(sum==n)
            printf(“\n%d is  Armstrong number”,n) ;
       }
     getch( ) ;
  }


/*Perfect Number*/

Definition:-Perfect number is a positive number whose sum of all positive divisors excluding that number is equal to that number is known as Perfect number.

For example: 6 is a perfect number , since divisor of 6 are 1,2 and 3. Sum of it's divisor is 1+2+3= 6

28=> 1,2,4,7,14        1+2+4+7+14 = 28

496,

8128.

Program :-
#include<stdio.h>
#include<conio.h>
void main( )
{
   int  n,i=1,sum=0,tmp ;
   clrscr( ) ;
   printf(“Enter any number:”) ;
   scanf(“%d”,&n) ;
   tmp=n ;
   while(i<n)
     {
       if (n%i ==0) 
        sum=sum+i ;
      i++;
     }
   if(sum==tmp)
     printf(“\n%d  is an Perfect number”,tmp);
   else
      printf(“\n%d is not an Perfect number”,tmp);
  getch();
}


/*Min & Max  range of an Perfect number*/
#include<stdio.h>
#include<conio.h>
void main()
{
   int min,max,n,sum=0,i,tmp ;
   clrscr() ;
   printf(“\nEnter min number:”) ;
   scanf(“%d”,&min) ;
   printf(“\nEnter max number:”) ;
   scanf(“%d”,&max) ;
   printf(“\nPerfect number is the given range:”) ;
   for(n=min;n<=max;n++)
     {
       i=1 ;
      sum=0 ;
      while(i<n)
        {
          if(n%i==0) 
            sum =sum+i ;
          i++ ;
        }
      if (sum ==n) 
        printf("\n%d is Perfect number”, n) ;
    }
  getch ( ) ;
}


/*Prime number*/

Definition:- A natural number greater than one has not any other divisors except 1 and itself.In other word we can say which has only two divisors 1 and number itself.

For example:- 5 divisiors are 1 and 5.

#include<stdio.h>
#include<conio.h>
void main( )
{
  int n,i=1,count=0 ;
  clrscr( ) ;
  printf("Enter any number") ;
  scanf("%d",&n) ;
  while(i <= n)
   {
      if( (n%i==0) && (n%n==0) )
      count++ ;
      i++ ;
   }
  if(count==2)
       printf("\n%d is a Prime number",n) ;
 else
       printf("%d is not a prime number",n) ;
 getch( ) ;
}


/*Prime number range in between min and max*/
#include<stdio.h>
#include<conio.h>
void main()
{
  int min,max,n,i,count;
  clrscr( );
  printf("\nEnter min number");
  scanf("%d",&min);
  printf("\nEnter max number");
  scanf("%d",&max);
  printf("\nPrime number in the given range:");
  for(n=min ; n<=max ; n++)
    {  
       i=1;
       count=0;
       while(i<=n)
          {
            if( (n%i==0) && (n%n==0) )
             count++;
            i++;
          }
       if(count == 2)
          pf("\n%d is Prime number”,n);
    }
 getch( );
}

/*Magic number*/

Definition:-A number is said to be a magic number if the reverse of the square of the number is equal to the given number reverse and its square.


For eg: (12) square =144 reverse of 144 is 441
            (21) square= 441

             (13) square=169 reverse of 169 is 961
             (31) square=691


Program:-
#include<stdio.h>
#include<conio.h>
void main ()
{
  int , i ,j,k,n ;
  clrscr( ) ;
  printf(“Enter  any  number”) ;
  scanf(“%d”, &n) ;
  while (i>n)
   {
     i=n*n ;
     j=0 ;
    while(i>0)
      {
         j=j * 10 + i % 10 ;
         i = i / 10 ;
      }
     i=n ;
     k=0 ;
     while(i>0)
       {
         k=k*10+i%10 ;
         i=i/10 ;
       }
     if(k*k==j)
       printf (“\nMagic  number”) ;
     else
        printf (“\nNot a Magic  number” ) ;
   }
 getch();
}


/*Magic number range in between min and max*/
#include<stdio.h>
#include<conio.h>
void main ( )
{
   int i,j,k,n,min,max  ;
   clrsccr() ;
   printf (“\nEnter min number “) ;
   scanf(“%d”,&min );
   printf (“\nEnter max number” ) ;
   scanf(“%d”,&max) ;
   for (n=min;  n<=max  ; n++)
    {
      i=n*n ;
     j=0 ;
    while(i>0)
      {
         j=j * 10 + i % 10 ;
         i = i / 10 ;
      }
     i=n ;
     k=0 ;
     while(i>0)
       {
         k=k*10+i%10 ;
         i=i/10 ;
       }
     if (k * k == j)
         printf (“\n%d  is a Magic number” , n );
    } 
  getch() ;
}


/*Palindrome number */

Definition: A number is caller palindrome number if it remain some when it's digits are reversed

For Example   : 121 is palindrome number, when we will increase ln digit it will remain same number i. e  121

Program :- 
#include <stdio.h>
#include <conio.h>
void main( ) 
{
  int n, r, tmp, sum=0 ;
  clrscr( ) ;
  printf(" Enter any number ") ;
  scanf("%d ", &n) ;
  tmp=n ;
  while (tmp) 
   {
     r=n%10 ;
     r=n/10 ;  
    sum= sum * 10 +r ;
   }
  if (sum ==tmp) 
       printf("\n%d is a Palindrome number ", tmp) ;
  else
       printf("\n%d is not a Palindrome number ",) ;
  getch( ) ;
 }


/* Palindrome number range in between min and max */
#include<stdio.h>
#include<conio.h>
void main ( )

  int  min, max, n, r,sum=0, tmp ;
  clrscr( ) ;
  printf ("\nEnter min number: ") ;
  scanf(“%d”,&min) ;
  printf(“\nEnter max number:”) ;
  scanf ("%d", &max) ;
  printf (" \nPalindrome number in the given range ") ; 
  for ( n=min, n<=max; n++)
   { 
      tmp=n ;
      sum=0 ;
      while (tmp) 
        {
           r=tmp%10 ;
           tmp=tmp/10 ;
           sum=sum * 10 + r ;
         }
       if (sum==n) 
          printf ("\n%d is Palindrome number ", n) ;
    }
  getch( ) ;
 }


/* Reverse the given number & sum */
#include<stdio.h>
#include<conio.h>
void main( )
{
  int n,r,tmp,rev=0,sum=0;
  clrscr( );
  printf("Enter any number");
  scanf("%d",&n);
  tmp=n;
  while(n)
     {
        r=n%10;
        n=n/10;
        rev=rev*10+r;
        sum=sum+r;
      }
  printf("\n%d Reverse number is %d:",tmp,rev);
  printf("\n sum of the reverse number is %d:",sum);
  getch( );
}


/*Factorial of a given number*/
 #include<stdio.h>
 #include<conio.h>
 void main( )
 {
   int n,f=1,tmp;
   clrscr( );
   printf("Take any number");
   scanf("%d",&n);
    tmp=n;
    while(n)
      {
        f=f*n;
        n--;
      }
      printf("\n%d factorial is %d",tmp,f);
   getch( );
  }

output :- Enter any number : 4

              4 factorial is      24 


/*Write a ‘C’ program to illustrate Fibonacci series*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
  int n;i,past=0,present=1,future;
  clrscr();
  printf(“enter any number: “);
  scanf(“%d”,&n);
  printf(“%d%d”,past,present);
  future=past+present;
  printf(“%d”,future);
  for(i=0;i<n-3;i++)
    {
       past=present;
       present=future;
       future = past + present;
       printf("\t %d", future );
    }
  getch();
}


Input: n=5


Output:        0          1         1

                 Past      present      future

                  0                 1           1               2

                           Past       present      future

                   0               1              1         2           3

                                                       Past      present     future


Programs in turboc3 : Files

File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...