Code
Create a Structure named student.
Write a program to read a record of 10 students and display only the record of those students whose address is "DHARAN"
Rate
#include
#include
#include
#include
typedef struct student
{
int rollno;
char name[20];
int age;
char address[20];
}std;
std s[10];
void addRecord(int i)
{
printf("Enter student's Rollno., name, age and address:\n");
scanf("%d%s%d%s", &(s[i].rollno), s[i].name, &(s[i].age), &(s[i].address));
printf("Record Added\n");
}
void displayRecord(int i)
{
printf("%d\t%s\t%d\t%s\n", s[i].rollno, s[i].name, s[i].age, s[i].address);
}
int main()
{
int i = 0;
while(i<3){
addRecord(i);
getch();
i++;
}
i = 0;
while(i<3){
if (strcmp(s[i].address, "DHARAN")==0)
{
displayRecord(i);
}
i++;
}
return 0;
}
Add comment:
Total 0 comments