#include <stdio.h> #include <string.h> #define MAX_STUDENTS 100 struct student { int roll; char name[50]; int age; }; int main() { int n, i; struct student students[MAX_STUDENTS]; printf("Enter the number of students: "); scanf("%d", &n); // Input student data for (i = 0; i < n; i++) { printf("Enter roll number for student %d: ", i+1); scanf("%d", &students[i].roll); printf("Enter name for student %d: ", i+1); scanf("%s", students[i].name); printf("Enter age for student %d: ", i+1); scanf("%d", &students[i].age); } // Display student data printf("\nStudent details:\n"); for (i = 0; i < n; i++) { printf("Roll number: %d\n", students[i].roll); printf("Name: %s\n", students[i].name); printf("Age: %d\n", students[i].age); printf("\n"); } return 0; }
Write a C program to input roll, name and age of n no of students and display them properly using structure.
Question collected from Telegram Group
Getting Info...