Problem Description
Write a program , using a pointer to a structure to initialize the members of the structure to display the students course registration details where details of first student initialized in the program and details of second student get from the user , then display the details of both student 1 and student 2
Input and Output Format:
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.
Note:
Use structure and union conceptsCODING ARENA
#include <stdio.h>
struct student
{
int rollno;
char name[10];
char dp[5];
int fees;
}s;
int main()
{
scanf("%d",&s.rollno);
scanf("%s",s.name);
scanf("%s",s.dp);
scanf("%d",&s.fees);
printf("Roll no:%d\n",s.rollno);
printf("Name:%s\n",s.name);
printf("Course:%s\n",s.dp);
printf("Fees:%d\n",s.fees);
return 0;
}
Test Case 1
Input (stdin)12 ram it 2333
Expected OutputRoll no:12 Name:ram Course:it Fees:2333
Test Case 2
Input (stdin)15 john cse 15000
Expected OutputRoll no:15 Name:john Course:cse Fees:15000
No comments:
Post a Comment