Thursday, November 27, 2014

C program to process the student‟s information (like inserting, displaying, searching etc.) Use the structures to store student's data

/*………………………………………………………………………………………………
File name: rec22.c
Program : A menu driven program using function of subprogram to process the student‟s information (like inserting, displaying, searching etc.) Use the structures to store student's
data
Author : sujithbaby440@gmail.com
Date : 22-11-2014
………………………………………………………………………………………………..*/
#include<stdio.h>
#include<stdlib.h>
typedef struct StudentType{
int SID;
char Name[30];
int Mrk1;
int Mrk2;
int Mrk3;
int Total;
float Avg;
int Result;
}Student;
Student s[20];
int N;
/*-------------------Prototype----------------*/
void fnMenu();
void fnEnterStudData();
void fnDispConsolR();
void fnDispIndRes();
main()
{
system("clear");
int ch;
printf("Program to create consolidated marks card\n");
fnMenu();
scanf("%d",&ch);
while(ch){
switch(ch){
case 1: fnEnterStudData();
fnMenu();
scanf("%d",&ch);
break;
case 2: fnDispConsolR();
fnMenu();
scanf("%d",&ch);
break;
case 3: fnDispIndRes();
fnMenu();
scanf("%d",&ch);
break;
case 4: exit(1);
break;
default:
fnMenu();
scanf("%d",&ch);
break;
}
}
}
/*----------------End of the main--------------------*/
/*-----------------Code subprogram--------------------*/
void fnMenu(){
printf("\t\t\t--------AIMIT----------\n");
printf("\t\t St. ALOYSIUS COLLEGE,MANGALORE\n");
printf("\t\t1:Enter Student Data\n");
printf("\t\t2:Display Consolidated Markshreet\n");
printf("\t\t3:Display Individual Student Marksheet\n");
printf("\t\t4:Exit\n");
printf("\nEnter Your Choice\n");
}
/*-----------------Code subprogram--------------------*/
void fnEnterStudData(){
int i;
printf("Enter Limit\n");
scanf("%d",&N);
for(i=1;i<=N;i++){
printf("Enter student registration number\n");
scanf("%d",&s[i].SID);
printf("Enter student name:\n");
scanf("%s",&s[i].Name);
printf("Enter marks in chemistry\n");
scanf("%d",&s[i].Mrk1);
printf("Enter marks in Physics\n");
scanf("%d",&s[i].Mrk2);
printf("Enter marks in Maths\n");
scanf("%d",&s[i].Mrk3);
s[i].Total=s[i].Mrk1+s[i].Mrk2+s[i].Mrk3;
s[i].Avg=s[i].Total/3;
if(s[i].Mrk1>=35&&s[i].Mrk2>=35&&s[i].Mrk3>=35&&s[i].Avg){
if(s[i].Avg>70){
s[i].Result=4;
}else if(s[i].Avg>60){
s[i].Result=1;
}else if(s[i].Avg>50){
s[i].Result=2;
}else if(s[i].Avg>40){
s[i].Result=3;
}else{
s[i].Result=0;
}
}
}
}
/*-----------------Code subprogram--------------------*/
void fnDispConsolR(){
printf("-----------------------------------------------\n");
printf("\n\t\t\tAimit Student Result\n");
printf("SID\tNAME\t\tCHEM PHYSIC MATH \tTOTAL\tAVG\t\tSTATUS\n");
int i;
for(i=1;i<=N;i++){
printf("\n%d\t",s[i].SID);
printf("%s\t",s[i].Name);
printf("\t%d\t",s[i].Mrk1);
printf("%d\t",s[i].Mrk2);
printf("%d\t",s[i].Mrk3);
printf("%d\t",s[i].Total);
printf("%f",s[i].Avg);
if(s[i].Result==4){
printf("Distinction\n");
}else if(s[i].Result==1){
printf("First class\n");
}else if(s[i].Result==2){
printf("Second class\n");
}else if(s[i].Result==3){
printf("Pass class\n");
}else{
printf("Fail\n");
}
}
}
void fnDispIndRes(){
int i,skey,flag=0,id;
printf("Enter the Student SID to display Individual Marksheet:\n");
scanf("%d",&skey);
printf("%d ",N);
for(i=1;i<=N;i++){
if(s[i].SID==skey){
flag=1;
id=i;
}
}
if(flag==1){
system("clear");
printf("\n\t\t\tAimit Student Result\n");
printf("----------------------------------\n");
printf("SID\tNAME\tCHEM PHYSIC MATH \tTOTAL\tAVG\t\tSTATUS\n");
printf("\n%d\t",s[id].SID);
printf("%s\t",s[id].Name);
printf("\t%d\t",s[id].Mrk1);
printf("%d\t",s[id].Mrk2);
printf("%d\t",s[id].Mrk3);
printf("%d\t",s[id].Total);
printf("%f",s[id].Avg);
if(s[i].Result==4){
printf("Distinction\n");
}else if(s[id].Result==1){
printf("First class\n");
}else if(s[id].Result==2){
printf("Second class\n");
}else if(s[id].Result==3){
printf("Pass class\n");
}else{
printf("Fail\n");
}
printf("------------------------------------------------\n");
}else{
printf("Invalid Result\n");
}
}
OUTPUT 1
Program to create consolidated marks card
--------AIMIT----------
St. ALOYSIUS COLLEGE,MANGALORE
1:Enter Student Data
2:Display Consolidated Mark sheet
3:Display Individual Student Mark sheet
4:Exit
Enter Your Choice
1
Enter Limit
2
Enter student registration number
141
Enter student name:
sooraj
Enter marks in chemistry
89
Enter marks in Physics
33
Enter marks in Maths
99
Enter student registration number
142
Enter student name:
ajay
Enter marks in chemistry
88
Enter marks in Physics
90
Enter marks in Maths
90
--------AIMIT----------
St. ALOYSIUS COLLEGE,MANGALORE
1:Enter Student Data
2:Display Consolidated Mark sheet
3:Display Individual Student Mark sheet
4:Exit
Enter Your Choice
2
-----------------------------------------------
Aimit Student Result
SID NAME CHEM PHYSIC MATH TOTAL AVG STATUS
141 sooraj 89 33 99 221 73.000000 Fail
142 ajay 88 90 90 268 89.000000 Distinction
--------AIMIT----------
St. ALOYSIUS COLLEGE,MANGALORE
1:Enter Student Data
2:Display Consolidated Mark sheet
3:Display Individual Student Mark sheet
4:Exit
Enter Your Choice
3
Enter the Student SID to display Individual Mark sheet:
142
Aimit Student Result
----------------------------------
SID NAME CHEM PHYSIC MATH TOTAL AVG STATUS
142 ajay 88 90 90 268 89.000000 Distinction
------------------------------------------------
--------AIMIT----------
St. ALOYSIUS COLLEGE,MANGALORE
1:Enter Student Data
2:Display Consolidated Mark sheet
3:Display Individual Student Mark sheet
4:Exit
Enter Your Choice
4
[141740@localhost ~]$

No comments:

Post a Comment