Answer to Question #208648 in C for Swetha

Question #208648

Develop a C program for File Operations that stores n number of the Alphabets from A to Z in a file and display it.

Runtime Input :

11

80

Output :

P

Q

R

S

T


1
Expert's answer
2021-06-20T08:12:33-0400
#include<stdio.h>
#include<stdlib.h>
int main(){
	char alphabet[26] ={'A','B','C','D','E','F','G','H','I','J','K','L','N','M','O','P','Q','R','S','T','U','W','X','Y','Z'};
	int i;
	FILE *newfile;
	newfile = fopen("data5.txt","w");
	for( i = 0; i<6; i++){
		printf("%c", alphabet[i]);
		fprintf(newfile, "%c",alphabet[i]);
	}
	FILE *file1;
	char element[6];
	file1 = fopen("data5.txt","r");
	while(fscanf(file1,"%s",element)!=EOF){
		printf("%s",element);
	}
	fclose(file1);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS