A program in ‘C’ language which accepts enrollment number as input and prints the name of student. pairs of students in the form of a matrix. 10m Dec2007

By | June 10, 2015

Write a program in ‘C’ language which accepts the enrollment number of a student as input and prints the name of that student. The program should initially store information about the (name, enrollment number) pairs of students in the form of a matrix. 10m Dec2007

 

#include<stdio.h>
struct student
{
unsigned long int ENROL;
char NAME[15];
}STUD[12]={
{102038400,”GANESH”},
{102038401,”MAHESH”},
{102038402,”SURESH”},
{102038403,”KALPESH”},
{102038404,”RAHUL”},
{102038405,”SUBBU”},
{102038406,”RAKESH”},
{102038407,”ATUL”},
{102038408,”DHARMESH”},
{102038409,”AJAY”},
{102038410,”ABDUL”},
{102038411,”RASHMI”}
};
void main()
{

unsigned long int ENROL;
clrscr();
printf(“ENTER THE Enroll bwtn 102038400 to 8411 : “);
scanf(“%ld”,&ENROL);
if(ENROL>102038399 && ENROL<102038412)
{
printf(“\n\n\tENROLMENT NO.\t: %ld”,ENROL);
printf(“\n\tNAME\t\t: %s”,STUD[ENROL-102038400].NAME);
}
else
printf(“\nYOU HAVE ENTERED WRONG ENROLMENT NO. !!”);
getch();
}

 

Code:

#include<stdio.h>
struct student
{
unsigned long int ENROL;
char NAME[15];
}STUD[12]={
{102038400,"GANESH"},
{102038401,"MAHESH"},
{102038402,"SURESH"},
{102038403,"KALPESH"},
{102038404,"RAHUL"},
{102038405,"SUBBU"},
{102038406,"RAKESH"},
{102038407,"ATUL"},
{102038408,"DHARMESH"},
{102038409,"AJAY"},
{102038410,"ABDUL"},
{102038411,"RASHMI"}
};
void main()
{
unsigned long int ENROL;
clrscr();
printf("ENTER THE Enroll bwtn 102038400 to 8411 : ");
scanf("%ld",&ENROL);
if(ENROL>102038399 && ENROL<102038412)
{
printf("\n\n\tENROLMENT NO.\t: %ld",ENROL);
printf("\n\tNAME\t\t: %s",STUD[ENROL-102038400].NAME);
}
else
printf("\nYOU HAVE ENTERED WRONG ENROLMENT NO. !!");
getch();
}

Screen Shots:

C_program_Student_Name_Matrix

C_program_Student_Name_Matrix_Output