FIFA-2022 Career Guide Free Tutorials Go to Your University Placement Preparation 
0 like 0 dislike
1.1k 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

Learn & Improve In-Demand Data Skills Online in this Summer With  These High Quality Courses[Recommended by GOEDUHUB]:-

Best Data Science Online Courses[Lists] on:-

Claim your 10 Days FREE Trial for Pluralsight.

Best Data Science Courses on Datacamp
Best Data Science Courses on Coursera
Best Data Science Courses on Udemy
Best Data Science Courses on Pluralsight
Best Data Science Courses & Microdegrees on Udacity
Best Artificial Intelligence[AI] Courses on Coursera
Best Machine Learning[ML] Courses on Coursera
Best Python Programming Courses on Coursera
Best Artificial Intelligence[AI] Courses on Udemy
Best Python Programming Courses on Udemy

Related questions

 Important Lists:

Important Lists, Exams & Cutoffs Exams after Graduation PSUs

 Goeduhub:

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

 

Free Online Directory

...