School Register prototype using C programming language.
/*
My aim for writing this program is to get student names
from multiple class.
for example: class 1 student 1 name, student 2 name,...... student n name.
same with class 2, class 3,........,class n;
and It is also my way to practice about struct;
*/
#include<stdio.h>
// struct to intake student name and roll no.
struct school{
/*I have declared two dimensional array because
1st array is for no. of students and 2nd is for
size of array in this case size of student's name. */
char name[100][10];
int rollno[100];
};
int main(){
struct school class[100];
int cl, std;
printf("***********************\n");
printf("| XYZ SCHOOL REGISTER |\n");
printf("***********************\n");
printf("enter no. of classes:");
scanf("%d", &cl);
printf("Enter no. of students: ");
scanf("%d", &std);
printf("\n");
for(int i = 0; i<cl; i++){
for(int j = 0; j<std; j++){
printf("Enter class %d student %d name:", i+1, j+1);
scanf("%s", class[i].name[j]);
printf("enter class %d student %d rollno:", i+1, j+1);
scanf("%d", &class[i].rollno[j]);
printf("\n");
}
printf("\n");
}
for(int i = 0; i<cl; i++){
printf("*******************************\n");
printf("|| class %d students details ||\n", i+1);
printf("*******************************\n");
for(int j = 0; j<std; j++){
printf("name: %s\n", class[i].name[j]);
printf("rollno: %d\n", class[i].rollno[j]);
printf("\n");
}
printf("\n");
}
return 0;
}
Comments
Post a Comment