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
U
V
W
X
Y
Z
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>//Standart Library -using FILE for work file function
#include <stdio.h>//Standart input output Library
int main()
{
int n;//Count the alphabet form A to Z
int beginCode;//Begining ACSSI code for example 80-P or 65 -A [65,97]=[A..Z]
scanf("%i", &n);//Scanner n
scanf("%i", &beginCode);//..
FILE* fl;//FILE handler
fl = fopen("alphabet.txt", "w+");//Write to alphabet txt file
char ch = (char)beginCode;
for (int i = 0; i < n; i++)
{
printf("%c\n", ch);
fprintf(fl, "%c\n", ch);
ch++;
}
fclose(fl);//Closing file
return 0;
}
//Test example
/*
Input
11
80
Output
P
Q
R
S
T
U
V
W
X
Y
Z
Test verify
*/
Comments
Leave a comment