You are on page 1of 8

1. Write a C program to read regno.

, name and marks of n number of students and store them


in a text file.

c code:
#include <stdio.h>
#include <stdlib.h>
int main() {
char name[50];
char regno[10];
int marks,i,n;
printf("Enter number of students: ");
scanf("%d",&n);
FILE *fptr;
fptr=(fopen("D:\\my0158assignment.txt","w"));
if(fptr==NULL) {
printf("Error!");
exit(1);
}
for (i=0;i<n;++i) {
printf("For student%d\nEnter registration number: ",i+1);
scanf("%s",regno);
printf("Enter name: ");
scanf("%s",name);
printf("Enter marks: ");
scanf("%d",&marks);
fprintf(fptr,"\nRegno: %s \nName: %s \nMarks=%d \n",regno,name,marks);
}
fclose(fptr);
return 0;
}

code screenshot:
User input/ Output screenshot:
Output file:
2. Write a C program to print the m-n lines from a file? Where m and n line numbers.

The input text file:


Input text is:

Regno: 20bci0111
Name: abc
Marks=200

Regno: 20bci0123
Name: xyz
Marks=30

Regno: 20bci0758
Name: fkuyfvjhvj,h
Marks=80

Regno: 20bce5555
Name: okaywhut
Marks=99

Regno: 20bce1152
Name: something
Marks=100

Paratext is a concept in literary interpretation.


The main text of published authors is often surrounded by other material supplied by
editors, printers, publishers,
which is known as the paratext.
These added elements form a frame the main text, can change the reception of a text its
interpretation by the public.
Paratext is most often associated with books, as they typically include a cover, title, front
matter, back matter footnotes,
many other materials crafted by the author. Other editorial decisions can also fall into the
category of paratext, such as
the formatting typography. Because of their close association with the text, it seems that
authors should be given the final say about
paratextual materials, but often that is. One recent example of controversy surrounding
paratext is the of the young
adult novel Liar, which was initially published with an image of a white girl on the cover,
although the
narrator of the story was identified in the text as black. The concept of paratext is closely
related to the concept of hypotext,
which is the earlier text that serves as a source for the current text.

c code:
#include <stdio.h>
#include <stdbool.h>

int main(int argc, char *argv[]) {

FILE *file = fopen("D:\\my0158assignment.txt", "r");

bool copy_characters = false;


int line_number = 1;
int desired_line;
int m,n;

printf("Enter the starting and ending line: ");


scanf("%d %d", &m, &n);
for(int i=m;i<=n;i++){
desired_line=i;
for (;;) {
int c = fgetc(file);
if (EOF == c) {
break;
} else if ('\n' == c) {
++line_number;
if (desired_line == line_number) {
copy_characters = true;
} else if (copy_characters) {
break;
}
} else if (copy_characters) {
putchar(c);
}
}
putchar('\n'); }
fclose(file);
return 0;
}

code screenshot:

Output screenshot:

You might also like