Program 30
Program 30
Program: a. Write a C program to read a text file ‘Demo.txt’ and print each word of that file
1.30
in reverse order.
Example:
Input: HELLO
Output: OLLEH
b. You are building a simple student marks recording system that:
1. Writes students' marks to a file.
2. Reads the marks from the file.
The program will use:
I putw() to write the marks (integer values) into the file.
II getw() to read the marks from the file.
III fopen() and fclose() to open and close the file
Code A.
#include <stdio.h>
void main()
{
FILE *F1;
char name[50], rev_note[50];
int i, j;
int length = 0;
int number;
F1 = fopen("revers", "w");
gets(name);
fclose(F1);
F1 = fopen("revers", "r");
printf("\n Display :\n");
Output
CEUC101: Computer concepts & Programming 24AIML019__ Hitarth Khatiwala
CEUC101: Computer concepts & Programming 24AIML019__ Hitarth Khatiwala