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
#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);
}
Comments
Leave a comment