Created
July 12, 2020 10:18
-
-
Save AakashCode12/4f61e415937fc6ddcf817faaa457ed50 to your computer and use it in GitHub Desktop.
C menu driven program for adding and displaying students information such as Roll-number, Name, Phone Number, Marks etc using structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
todo : C menu driven program for adding and displaying students information such as Roll-number, Name, Phone Number, Marks etc using structure | |
?Assignment -1 Data Structures & Algorithms | |
*/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
//!structure declarations | |
struct details | |
{ | |
char name[30]; | |
int roll_no; | |
int phone_no; | |
int marks; | |
}student[5]; | |
// All the function of our program. | |
void search_roll(int x) | |
{ | |
int id,i; | |
printf("\nEnter Student's Roll no to be Searched : "); | |
scanf("%d",&id); | |
printf("☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻\n"); | |
for(i=0;i<x;i++) | |
{ | |
if(student[i].roll_no==id) | |
{ | |
printf("\nName : %s",student[i].name); | |
printf("\nRoll no : %d",student[i].roll_no); | |
printf("\nPhone no : %d",student[i].phone_no); | |
printf("\nMarks : %d\n",student[i].marks); | |
} | |
} | |
} | |
void search_phone(int x) | |
{ | |
int id,i; | |
printf("\nEnter Student's Phone no to be Searched : "); | |
scanf("%d",&id); | |
printf("☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻\n"); | |
for(i=0;i<x;i++) | |
{ | |
if(student[i].phone_no==id) | |
{ | |
printf("\nName : %s",student[i].name); | |
printf("\nRoll no : %d",student[i].roll_no); | |
printf("\nPhone no : %d",student[i].phone_no); | |
printf("\nMarks : %d\n",student[i].marks); | |
} | |
} | |
} | |
void display(int x) | |
{ | |
int i; | |
printf("\nList of All Students:\n"); | |
printf("-------------------------------\n"); | |
printf("Name \tRollno Phone_no Marks \n"); | |
printf("--------------------------------\n"); | |
for(i=0;i<x;i++) | |
{ | |
printf("%s\t %d\t %d\t %d\n",student[i].name,student[i].roll_no,student[i].phone_no,student[i].marks); | |
} | |
printf("\n"); | |
} | |
//main function | |
int main() | |
{ | |
int n,i,ch; | |
printf("**How Many Student's Record You Want to Add**\nEnter Limit : "); | |
scanf("\n %d",&n); | |
for(i=0;i<n;i++) | |
{ | |
printf("-----------------------------------------"); | |
printf("\n\tEnter Details of Student=%d",i+1); | |
printf("\n-----------------------------------------"); | |
printf("\nName of the student : "); | |
scanf("%s",&student[i].name); | |
printf("Roll no of the student : "); | |
scanf("%d",&student[i].roll_no); | |
printf("Phone no of the student : "); | |
scanf("%d",&student[i].phone_no); | |
printf("Marks of the student : "); | |
scanf("%d",&student[i].marks); | |
} | |
while(1) | |
{ | |
printf("-----------------------------------------\n"); | |
printf("☺☺☺☺☺------Main Menu------☺☺☺☺☺\n"); | |
printf("-----------------------------------------"); | |
printf("\n 1:Search Student by Roll no"); | |
printf("\n 2:Search Student by Phone no"); | |
printf("\n 3:List of All Students"); | |
printf("\n 4:Exit"); | |
printf("\n----------------------------------------\n"); | |
printf("Enter Your Choice : "); | |
scanf("\n %d",&ch); | |
switch(ch) | |
{ | |
case 1: search_roll(n); | |
break; | |
case 2: search_phone(n); | |
break; | |
case 3: display(n); | |
break; | |
case 4: exit(0); | |
break; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment