C++ Program Write a ‘C’ program to do following aCreate a text file ‘input.txt’ b.Print the contents of file in reverse order




#include<stdio.h>
#include<conio.h>
void main()
{
 FILE *fp;
 char ch,s[100];
 int i=0;
 clrscr();
 printf("Enter the content of file\n");
 fp=fopen("E:\input.txt","w");
 while((ch=getchar())!=EOF)
 {
  fputc(ch,fp);
  }
  fclose(fp);
  fp=fopen("E:\input.txt","r");
  while((s[i]=fgetc(fp))!=EOF)
  {
   i++;
   }
   while(i>=0)
   {
    printf("%c",s[i]);
    i--;
   }
   fclose(fp);
  getch();
  }

/* output
Enter the content of file
india is my country
all indians^Z
 snaidni lla
yrtnuoc ym si aidni
*/