Program:
#include <stdio.h>
struct student
{
char name[50],gender[10];
int roll;
float fees;
} s[25];
int main()
{
int i,n;
printf("Enter information of students:\n");
printf("--> Enter the No. of Students: ");
scanf("%d",&n);
// storing information
for(i=0; i<n; i++)
{
printf("_____________________________________________________________\n");
printf("<<<<For Student:%d >>>>\n",i+1);
printf("Enter Roll No.-: ");
scanf("%d",&s[i].roll);
printf("Enter name: ");
scanf("%s",s[i].name);
printf("Enter Gender: ");
scanf("%s",s[i].gender);
printf("Enter Fees: ");
scanf("%f",&s[i].fees);
printf("\n");
}
printf("***************************************************************\n");
printf("\t\t>>>Displaying Students Information:>>>\n\n");
// displaying information
for(i=0; i<n; ++i)
{
printf("-----------------------------------------------------------\n");
printf("\n\tRoll number: %d\n",s[i].roll);
printf("\n\tName: ");
puts(s[i].name);
printf("\n\tGender:");
puts(s[i].gender);
printf("\n\tFees: %.1f $",s[i].fees);
printf("\n");
}
printf("-----------------------------------------------------------\n");
return 0;
}
struct student
{
char name[50],gender[10];
int roll;
float fees;
} s[25];
int main()
{
int i,n;
printf("Enter information of students:\n");
printf("--> Enter the No. of Students: ");
scanf("%d",&n);
// storing information
for(i=0; i<n; i++)
{
printf("_____________________________________________________________\n");
printf("<<<<For Student:%d >>>>\n",i+1);
printf("Enter Roll No.-: ");
scanf("%d",&s[i].roll);
printf("Enter name: ");
scanf("%s",s[i].name);
printf("Enter Gender: ");
scanf("%s",s[i].gender);
printf("Enter Fees: ");
scanf("%f",&s[i].fees);
printf("\n");
}
printf("***************************************************************\n");
printf("\t\t>>>Displaying Students Information:>>>\n\n");
// displaying information
for(i=0; i<n; ++i)
{
printf("-----------------------------------------------------------\n");
printf("\n\tRoll number: %d\n",s[i].roll);
printf("\n\tName: ");
puts(s[i].name);
printf("\n\tGender:");
puts(s[i].gender);
printf("\n\tFees: %.1f $",s[i].fees);
printf("\n");
}
printf("-----------------------------------------------------------\n");
return 0;
}
Expected O/P:
Enter information of students:
--> Enter the No. of Students: 2
_____________________________________________________________
<<<<For Student:1 >>>>
Enter Roll No.-: 1
Enter name: Rahul
Enter Gender: Male
Enter Fees: 1500
_____________________________________________________________
<<<<For Student:2 >>>>
Enter Roll No.-: 2
Enter name: Anjali
Enter Gender: Female
Enter Fees: 1000
***************************************************************
>>>Displaying Students Information:>>>
-----------------------------------------------------------
Roll number: 1
Name: Rahul
Gender:Male
Fees: 1500.0 $
-----------------------------------------------------------
Roll number: 2
Name: Anjali
Gender:Female
Fees: 1000.0 $
-----------------------------------------------------------
Enter information of students:
--> Enter the No. of Students: 2
_____________________________________________________________
<<<<For Student:1 >>>>
Enter Roll No.-: 1
Enter name: Rahul
Enter Gender: Male
Enter Fees: 1500
_____________________________________________________________
<<<<For Student:2 >>>>
Enter Roll No.-: 2
Enter name: Anjali
Enter Gender: Female
Enter Fees: 1000
***************************************************************
>>>Displaying Students Information:>>>
-----------------------------------------------------------
Roll number: 1
Name: Rahul
Gender:Male
Fees: 1500.0 $
-----------------------------------------------------------
Roll number: 2
Name: Anjali
Gender:Female
Fees: 1000.0 $
-----------------------------------------------------------
0 Comments
Post a Comment