95.5k views
3 votes
Wap to input roll name address and mark of 100 student and display them using structure


User Ofornes
by
8.1k points

1 Answer

5 votes

Answer:

Here's an example program in C that uses structures to input and display information for 100 students:

scss

Copy code

#include <stdio.h>

struct Student {

int roll;

char name[50];

char address[100];

float mark;

};

int main() {

struct Student s[100];

int i;

// Input information for each student

for(i = 0; i < 100; i++) {

printf("Enter information for student %d:\\", i+1);

printf("Roll number: ");

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

printf("Name: ");

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

printf("Address: ");

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

printf("Mark: ");

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

}

// Display information for each student

printf("Student Information:\\");

for(i = 0; i < 100; i++) {

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

printf("Name: %s\\", s[i].name);

printf("Address: %s\\", s[i].address);

printf("Mark: %.2f\\", s[i].mark);

printf("\\");

}

return 0;

}

This program declares a structure called Student that contains fields for roll number, name, address, and mark. It then creates an array of 100 Student structures and uses a loop to input information for each student. Finally, it uses another loop to display the information for each student.

User Tresha
by
7.9k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.