Q:

Write a c program to demonstrate array of structure

0

Write a c program to demonstrate array of structure

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

#include<stdio.h>
#include<conio.h>
#define MAX 2
struct student
{
char name[20];
int rollno;
float marks;
};
int main()
{
struct student arr_student[MAX];
int i,j;
float sum=0;
for(i=0;i<MAX;i++)
{
printf("\n Enter detials of student %d\n\n",i+1);
printf("Enter name:");
scanf("%s",arr_student[i].name);

printf("Enter roll no.:");
scanf("%d",&arr_student[i].rollno);

printf("Enter marks:");
scanf("%f",&arr_student[i].marks);

}
printf("\n");
printf("Name\t Rollno.\tmarks\n\n");

for(i=0;i<MAX;i++)
{
printf("%s\t%d\t%.2f\n",arr_student[i].name,arr_student[i].rollno,arr_student[i].marks);
}
return 0;
}

Output:

Enter detials of student 1

Enter name:Tushar
Enter roll no.:14
Enter marks:68

 Enter detials of student 2

Enter name:Nandini
Enter roll no.:34
Enter marks:89

Name	 Rollno.	marks

Tushar	14	68.00
Nandin	34	89.00

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming Exercises With Solutions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a program in c to demonstrate pointer to a p... >>
<< Write a program in c to input and print details of...