Program 30
Program 30
Program : 30 a. Write a C program to read a text file ‘Demo.txt’ and print each word
of that file 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:
putw() to write the marks (integer values) into the file. getw() to
read the marks from the file.
Code A:
#i nclude <stdio.h>
vo id main()
{
FILE *F1;
char name[50], rev_note[50]; int
i, j;
int length = 0; int
number;
F1 = fopen("revers", "w");
B:
#include <stdio.h>
void main()
{
FILE *F1; int number, i;
printf("Enter marks :");
F1 = fopen("marks", "w");
for (i = 0; i <= 5; i++)
{
scanf("%d", &number);
putw(number, F1);
}
fclose(F1);
F1 = fopen("marks", "r"); printf("\n Display the marks\n");
while ((number = getw(F1)) != EOF) printf("%d ", number);
fclose(F1);
printf("\n24AIML021_MAYUR ");
}
Output