Books Online Courses
Free Tutorials  Go to Your University  Placement Preparation 
Latest:- Important tips to get an Off Campus Placements
0 like 0 dislike
625 views
in GTU B.E. (CSE-I-Sem) Programming For Problem Solving Lab by Goeduhub's Expert (7.1k points)

Define a structure type struct personal that would contain person name, date of joining and salary using this structure to read this information of 5 people and print the same on screen.

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.1k points)
edited by
 
Best answer

In this program we are going to implement a structure Personal which contains name, date of joining and salary of employees.

To learn about structure and union from beginning Click Here.

Example :

#include<stdio.h>
#include<conio.h>

//Declaration of structure Personal
struct Personal{

//Structure data members declaration
int salary,date;
char name[100];
}per[5];
//Using an array to hold information of 5 employees

void main()
{
int i;
clrscr();

//Values are being inserted by user
printf("\nEnter the following information of employees:");
for(i=0;i<5;i++)
{
printf("\nEmployee %d\nName:",i+1);
scanf("%s",&per[i].name);
printf("\nJoining date(date and month as 2203):");
scanf("%d",&per[i].date);
printf("\nSalary:");
scanf("%d",&per[i].salary);
}

//Printing Employee information on output window
printf("\nEntered information is as follows:");
printf("\n|| S.No. ||      Name      ||    Salary    ||   Joining Date   |");
for(i=0;i<5;i++)
{
printf("\n|| %d     ||     %s          %d            %d     ",i+1,per[i].name,per[i].salary,per[i].date);
}
getch();
}

Output :

Output of above program showing structure operations


For More GTU C Programming Lab Experiments Click Here

3.3k questions

7.1k answers

395 comments

4.6k users

Related questions

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...