Aarav, Advika, binitta are good friends. They are studying final year B.E. Computer Science and Engineering. They want to develop an application to order student details in ascending order which will be useful for the high school in the village they belong to.
Can you help them in the application development?
Input:
First-line n the number of students
Next line the name, department, year of study, and CGPA details of n students
Output:
Print the expected output in proper format
Note: Students details should be sorted based on their "Names" in ascending order
#include <stdio.h> #include <string.h> struct Student{ char name[50]; char department[5]; int yearOfStudy; float cgpa; }S1[100],t; int main() { int i=0,j=0,n; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%s %s %d %f",S1[i].name,S1[i].department,&S1[i].yearOfStudy,&S1[i].cgpa); } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(strcmp(S1[i].name,S1[j].name)>0){ t=S1[i]; S1[i]=S1[j]; S1[j]=t; } } } for(i=0;i<n;i++){ printf("Name:%s\n",S1[i].name); printf("Department:%s\n",S1[i].department); printf("Year of study:%d\n",S1[i].yearOfStudy); printf("CGPA:%.1f\n",S1[i].cgpa); } return 0; }
INPUT_1:
3
Binitta cse 1 7.8
Aarav IT 2 8.2
Adhvika swe 3 8.6
OUTPUT:
Name: Aarav
Department: IT
Year of study: 2
CGPA: 8.2
Name: Adhvika
Department: swe
Year of study: 3
CGPA: 8.6
Name: Binitta
Department: cse
Year of study: 1
CGPA: 7.8
INPUT_2:
1
stella cse 1 7.8
OUTPUT:
Name: stella
Department: cse
Year of study: 1
CGPA: 7.8
ILLUSTRATION
Morae Q!
- Find how long will it take till the next fortune year from the current year.
- Find if it’s possible to distribute all the crayons into boxes and satisfy all the conditions.
- Compute sum of numbers using call by reference.
- Compute the amount of money to be handed over with conditions.
- Find the total number of beautiful triplets in the sequence.
- Find the total amount each worker has to pay individually.
- Find the minimum distance between any pair of equal elements in the array.
- Compute the maximum possible value of the given equation.
- Find the age of the student at the time of joining.
- Compute the total number of photos at each restaurant .
- Find the sum of digits of the number using Union datatype.
- Generate the details of the novels in the expected format.
- Sort the student details based on their names in ascending order.
- Find a way to move the king from current position to different square on chessboard.
- Find the time differences in the two different time zones.
- Identifying the greatest number with a numerator and denominator.
- Find the Minimum number of packages to supply all the bases.
- Tower of Hanoi, A puzzle.
- Compute the sum of array of elements using recursion method.
- Find the super digit of an integer using the rules.