Thứ Năm, 27 tháng 6, 2019

[C] Tạo cấu trúc Struct

#include <stdio.h>
struct Person
{
    char name[50];
    int age;
    float salary;
};

int main ()
{
   Person p1;

   printf("Nhap gia tri: \n");

   printf("\nNhap ho ten: ");

    gets(p1.name);

   printf("Nhap tuoi:");
   scanf("%d",&p1.age);

   printf("Nhap muc luong: ");
   scanf("%f",&p1.salary);

   printf("\n===========================\n");
   printf("Thong tin cua nhan su:");
   printf("Ho ten: %s",p1.name);
   printf("\nTuoi: %d",p1.age);
   printf("\nMuc luong: %5.2f",p1.salary);
   return 0;

}

Không có nhận xét nào:

Đăng nhận xét