Computer Science, asked by sakshimuktagmailcom, 11 months ago

write a program to read and print the information of three student using structure ​

Answers

Answered by ridhimakh1219
2

Write a C program to read and print the information of three student using structure ​

Explanation:

C Program to Store Information of 3 students Using Structure

#include <stdio.h>

#include <conio.h>

// Create the student structure

struct student {

   char name[50];

   int roll;

   float marks;

};

void main()

{

   // Create the student's structure variable with 3 records

   struct student s[3];

   int i;

   printf("Enter information of students:\n");

   for(i=0;i<3;++i)

   {

       printf("Enter roll number: ");

       scanf("%d",&s[i].roll);

       printf("Enter name: ");

       scanf("%s",s[i].name);

       printf("Enter marks: ");

       scanf("%f",&s[i].marks);

   }

   printf("Displaying information of students:");

   for(i=0;i<3;++i)

   {

    printf("\n Information for roll number %d:\n",s[i].roll);

    printf("Name: ");

    puts(s[i].name);

    printf("Marks: %.1f",s[i].marks);

  }

  getch();

}

OUTPUT

Enter information of students:

Enter roll number: 34

Enter name: Dany

Enter marks: 78

Enter roll number: 67                    

Enter name: Nammy                          

Enter marks: 90                     

Enter roll number: 21                        

Enter name: kaur                                                                              

Enter marks: 45                    

Displaying information of students:  

Information for roll number 34:              

Name: Dany

Marks: 78.0                                          

Information for roll number 67:      

Name: Nammy                                                        

Marks: 90.0                                                        

Information for roll number 21:      

Name: kaur                                                  

Marks: 45.0              

Similar questions