License, disclaimer of liability, and limited warranty



Download 2,08 Mb.
Pdf ko'rish
bet331/393
Sana05.01.2022
Hajmi2,08 Mb.
#319699
1   ...   327   328   329   330   331   332   333   334   ...   393
Bog'liq
C Programming A Self Teaching Int 1uq45XL

OUTPUT (after running):
Enter name, age and salary of the 1st employee: Dr. Rajiv 40     82000.00
Enter name, age and salary of the 2nd employee: Mr. Sushant 30 50000.00
First Employee details …
Name: Dr. Rajiv


Age: 40
Salary: 82000.00
Second Employee details …
Name: Mr. Sushant
Age: 30
Salary: 50000.00
Initializations of Structures
Just as you initialize ints, floats, chars, and arrays, you can also initialize structure variables.
For example, in the previous structure Emp:
   struct Emp
    {
      char fname[40], lname[40];
      int age;
      float salary;
      char address[30], dept[30];
    };
Then a variable of this structure—say, emp1—can be initialized during its declaration as follows:
struct Emp emp1 = {“Rajiv”, Chopra”, 40, 82000.00, “GTB Nagar”, “Computer Science”};
Or you can also write as follows:
   struct Emp
    {
      char fname[40], lname[40];
      int age;
      float salary;
      char address[30], dept[30];
    }emp1 = {“Rajiv”, Chopra”, 40, 82000.00, “GTB Nagar”, “Computer Science”};
Here,
emp1.fname = “Rajiv”
emp1.lname = “Chopra”
emp1.age =40
emp1.salary = 82000.00
emp1.address = “GTB Nagar”
emp.dept = “Computer Science”
As we can assign one basic data type to another basic data type variable, similarly we can assign
a structure variable to another structure variable of the same type.
For example,
   struct Emp
    {
      char fname[40], lname[40];
      int age;
      float salary;
      char address[30], dept[30];
    };
struct Emp emp1 = {“Rajiv”, Chopra”, 40, 82000.00, “GTB Nagar”, “Computer Science”};


struct Emp emp2;
emp2 = emp1; /* is valid */
So now emp2 will have the same data as emp1 had.

Download 2,08 Mb.

Do'stlaringiz bilan baham:
1   ...   327   328   329   330   331   332   333   334   ...   393




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish