-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ8.c
35 lines (29 loc) · 949 Bytes
/
Q8.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <string.h>
// Define a structure for student
struct Student {
char name[50];
char rollNo[20];
float totalMarks;
};
// Function to display student details
void displayStudent(struct Student s) {
printf("Name: %s\n", s.name);
printf("Roll Number: %s\n", s.rollNo);
printf("Total Marks: %.2f\n", s.totalMarks);
}
int main() {
// Declare a variable of type struct Student
struct Student student;
// Read student details from the user
printf("Enter name of the student: ");
scanf("%s", student.name); // Assuming the name doesn't contain spaces
printf("Enter roll number of the student: ");
scanf("%s", student.rollNo);
printf("Enter total marks obtained by the student: ");
scanf("%f", &student.totalMarks);
// Display the student details
printf("\nStudent Details:\n");
displayStudent(student);
return 0;
}