0

Hello guys, I wanted to make a program that will print the details entered by user so what should I add to make it ???

#include <stdio.h> #include <string.h> #include <stdlib.h> union Students { int rollnum; char name; float marks; }; int main(void) { union Students s; int i = 0; printf("Enter a name of student 1: "); scanf("%s", &s.name); printf("Enter a roll number of student 1: "); scanf("%d", &s.rollnum); printf("Enter a marks of student 1: "); scanf("%f", &s.marks); printf("\vEnter a name of student 2: "); scanf("%s", &s.name); printf("Enter a roll number of student 2: "); scanf("%d", &s.rollnum); printf("Enter a marks of student 2: "); scanf("%f", &s.marks); printf("\vEnter a name of student 3: "); scanf("%s", &s.name); printf("Enter a roll number of student 3: "); scanf("%d", &s.rollnum); printf("Enter a marks of student 3: "); scanf("%f", &s.marks); printf("Students name = %s",s.name); return 0; }

31st Dec 2021, 9:57 AM
Mr. A
Mr. A - avatar
1 Odpowiedź
31st Dec 2021, 10:14 AM
Slick
Slick - avatar