Archived
26 lines
725 B
C
Executable File
26 lines
725 B
C
Executable File
/*
|
|
6.Создать структуру, содержащую два поля – NAME и AGE. Задать две переменные типа этой структуры. Ввести их значения с клавиатуры и вывести на экран.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
struct person {
|
|
char NAME[32];
|
|
int AGE;
|
|
};
|
|
|
|
int main() {
|
|
struct person p1, p2;
|
|
|
|
printf("Enter name and age first person: ");
|
|
scanf("%s %d", p1.NAME, &p1.AGE);
|
|
printf("Enter name and age second person: ");
|
|
scanf("%s %d", p2.NAME, &p2.AGE);
|
|
|
|
printf("First person: %s, %2d age\n", p1.NAME, p1.AGE);
|
|
printf("Second person: %s, %2d age\n", p2.NAME, p2.AGE);
|
|
|
|
return 0;
|
|
}
|