Programming for Problem Solving

GTU Practical 32

32. Write a C program to read and store the roll no and marks of 20 students using an array.
#include<stdio.h>  ( this applies in the given code )

#include

int main(void)
{
int rollno[20],marks[20],i;

for(i=0;i<20;i++) { printf("Enter Roll of Student [%d] : ",i+1); scanf("%d",&rollno[i]); printf("Enter Mark of Student [%d]: ",i+1); scanf("%d",&marks[i]); } for(i=0;i<20;i++) { printf("\n Roll No : %d Marks : %d",rollno[i],marks[i]); } return 0; }

OUTPUT

Enter Roll of Student [1] : 1
Enter Mark of Student [1]: 10
Enter Roll of Student [2] : 2
Enter Mark of Student [2]: 20
Enter Roll of Student [3] : 3
Enter Mark of Student [3]: 30
Enter Roll of Student [4] : 4
Enter Mark of Student [4]: 40
Enter Roll of Student [5] : 5
Enter Mark of Student [5]: 50
Enter Roll of Student [6] : 6
Enter Mark of Student [6]: 60
Enter Roll of Student [7] : 7
Enter Mark of Student [7]: 70
Enter Roll of Student [8] : 8
Enter Mark of Student [8]: 10
Enter Roll of Student [9] : 9
Enter Mark of Student [9]: 20
Enter Roll of Student [10] : 10
Enter Mark of Student [10]: 0
Enter Roll of Student [11] : 11
Enter Mark of Student [11]: 2
Enter Roll of Student [12] : 12
Enter Mark of Student [12]: 1
Enter Roll of Student [13] : 13
Enter Mark of Student [13]: 40
Enter Roll of Student [14] : 14
Enter Mark of Student [14]: 22
Enter Roll of Student [15] : 15
Enter Mark of Student [15]: 75
Enter Roll of Student [16] : 16
Enter Mark of Student [16]: 3
Enter Roll of Student [17] : 17
Enter Mark of Student [17]: 4
Enter Roll of Student [18] : 18
Enter Mark of Student [18]: 5
Enter Roll of Student [19] : 19
Enter Mark of Student [19]: 9
Enter Roll of Student [20] : 20
Enter Mark of Student [20]: 80

Roll No : 1 Marks : 10
Roll No : 2 Marks : 20
Roll No : 3 Marks : 30
Roll No : 4 Marks : 40
Roll No : 5 Marks : 50
Roll No : 6 Marks : 60
Roll No : 7 Marks : 70
Roll No : 8 Marks : 10
Roll No : 9 Marks : 20
Roll No : 10 Marks : 0
Roll No : 11 Marks : 2
Roll No : 12 Marks : 1
Roll No : 13 Marks : 40
Roll No : 14 Marks : 22
Roll No : 15 Marks : 75
Roll No : 16 Marks : 3
Roll No : 17 Marks : 4
Roll No : 18 Marks : 5
Roll No : 19 Marks : 9
Roll No : 20 Marks : 80

GTU STUDY