Question 1: Write a C program that stores student information in structure and display it.
Question 2: In addition to the first question, you are expected to create one more structure for courses. Then, structures must be filled by user inputs. After filling your structures, you will let user to get any student enroll to any course from the course list. Hint: To achieve these steps, you must use pointer in your student structure to link it to course structure.
Q.1) Store Information in Structure and Display it :
#include <stdio.h>
#include <conio.h>
struct student {
int roll;
char firstName[60];
float marks;
} s[10];
int main() {
int i;
printf("Please enter the information of students:\n");
// storing the information
for (i = 0; i < 5; ++i) {
s[i].roll = i + 1;
printf("\nFor roll number%d,\n", s[i].roll);
printf("Enter first name: ");
scanf("%s", s[i].firstName);
printf("Enter marks: ");
scanf("%f", &s[i].marks);
}
printf("Displaying Information:\n\n");
// displaying information
for (i = 0; i < 5; ++i) {
printf("\nRoll number: %d\n", i + 1);
printf("First name: ");
puts(s[i].firstName);
printf("Marks: %.1f", s[i].marks);
printf("\n");
}
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.