C : Program to accept 5 student deatails and print accepted details (use structure)

Programmer Portfolio
1 min readOct 25, 2023

--

Program :

//c program to accept 5 student deatails and print accepted details (use structure) 
// accept Roll no, Name, Address, Total Marks, Percentage

#include<stdio.h>

struct student
{
int rollno;
char name[100];
char add[150];
float tmarks;
float percentage;
};

int main()
{
struct student std[5];

//Accepting details from user
printf("HSC student colllege deatils :\n");
for(int i=1; i<=5; i++) {
printf("\nEnter details for student %d :\n", i);

printf("Enter Roll Number :");
scanf("%d", &std[i].rollno);


printf("Enter first name :");
scanf("%s", &std[i].name);


printf("Enter address :");
scanf("%s", &std[i].add);


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


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

}

//Printing accepted details
printf("\nStudent details :\n");
for(int i=1; i<=5; i++)
{
printf("\nStudent %d :\n", i);

printf("Roll number : %d\n", std[i].rollno);

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

printf("Address : %s\n", std[i].add);

printf("Total marks : %f\n", std[i].tmarks);

printf("Percentage : %f\n", std[i].percentage);

}
return 0;
}



Output :

Accepted output

Accepted from user

All details print

Print of all details

--

--

Programmer Portfolio
Programmer Portfolio

Written by Programmer Portfolio

Code enthusiast. Learning, practicing, and sharing my journey through various programming languages, one code at a time. 🚀💻

No responses yet