-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructures.c
More file actions
33 lines (25 loc) · 803 Bytes
/
Copy pathstructures.c
File metadata and controls
33 lines (25 loc) · 803 Bytes
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
#include <stdio.h>
#include <string.h>
// Structure to represent a student
struct Student {
char name[50]; // Array to store student's name
int id;
int age;
};
int main() {
struct Student student; // Create a structure variable
// Get student information from the user
printf("Enter student name: ");
fgets(student.name, 50, stdin);
student.name[strcspn(student.name, "\n")] = '\0'; // Remove trailing newline, if any
printf("Enter student ID: ");
scanf("%d", &student.id);
printf("Enter student age: ");
scanf("%d", &student.age);
// Print the stored student information
printf("\nStudent Information:\n");
printf("Name: %s\n", student.name);
printf("ID: %d\n", student.id);
printf("Age: %d\n", student.age);
return 0;
}