struct structureName { datatype member1 ; datatype member2 ; ---------------- };
struct student { int rollno; char name[20]; int age; char gender; };
struct employee
{
int empno;
char name[20];
char job[20];
int salary ;
};
struct book
{
char book_title[10];
char author[10];
int price;
int total_pages;
};
struct structureName { datatype member1; datatype member2; ----------------- } variablesList ;
struct student { int rollno; char name[20]; int age; char gender; }
#include<stdio.h>
struct student
{
int rollno;
char name[20];
int age;
char gender;
};
main()
{
struct student a;
printf("Enter RollNo Name Age and Gender : ");
scanf("%d %s %d %c",&a.rollno,a.name,&a.age,&a.gender);
printf("\nRollNo is %d",a.rollno);
printf("\nName is %s",a.name);
printf("\nAge is %d",a.age);
printf("\nGender is %c",a.gender);
}
#include<stdio.h>
struct person
{
char fname[20];
char lname[20];
int age;
};
main()
{
struct person a;
printf("Enter fname lname and age: ");
scanf("%s %s %d", a.fname, a.lname, &a.age);
if(a.age>=60)
printf("%s %s is Senior Citizen", a.fname, a.lname);
else
printf("%s %s is NOT Senior Citizen", a.fname, a.lname);
}
#include<stdio.h>
struct worker
{
char name[20];
int wages;
int wdays;
} ;
main()
{
struct worker a;
int p;
printf("Enter Name wages and wdays: ");
scanf("%s %d %d", a.name, &a.wages, &a.wdays);
p=a.wages*a.wdays;
printf("Payment of %s is %d", a.name , p);
}
#include<stdio.h>
struct worker
{
char name[20];
int wages;
int wdays;
};
main()
{
struct worker a, b;
int p1 , p2 , t;
printf("Enter Name wages and wdays: ");
scanf("%s %d %d", a.name, &a.wages, &a.wdays);
printf("Enter Name wages and wdays ");
scanf("%s %d %d", b.name, &b.wages, &b.wdays);
p1 = a.wages*a.wdays;
p2 = b.wages*b.wdays;
t = p1 + p2;
printf("\nPayment of %s is %d", a.name, p1 );
printf("\nPayment of %s is %d", b.name, p2 );
printf("\nTotal Payment is %d", t);
}