/*Program to print marks of students in ascending order using structure */ #include<stdio.h> int main() { int n,c,t; printf("Enter Total No Of Students\n"); scanf("%d",&n); c=getchar(); struct student { char name[100]; char section; int marks[5]; }s[n]; for(int i=0;i<n;i++) { printf("Enter Name :"); gets(s[i].name); printf("\n"); printf("Enter Section :"); scanf("%c",&s[i].section); printf("\n"); printf("Enter Marks In 5 Subjects \n"); for(int j=0;j<5;j++) { scanf("%d",&(s[i].marks[j])); } c=getchar(); } for(int i=0;i<n;i++) { for(int k=0;k<5;k++) { for(int j=0;j<4;j++) { if(s[i].marks[j]>s[i].marks[j+1]) { t=s[i].marks[j]; s[i].marks[j]=s[i].marks[j+1]; s[i].marks[j+1]=t; } } } } for(int i=0;i<n;i++) { printf("\n\nName\tSection\n"); printf("%s\t%c\t\n",s[i].name,s[i].section); printf("Marks In 5 Subjects \n"); for(int j=0;j<5;j++) { printf("%d \n",(s[i].marks[j])); } } return 0; }
IDE
getchar
return 0;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)