Friday, March 11, 2011

Structures and Unions

Define a structure type, struct personal that would contain person name, date of joining and salary. Using this structure,write a program to read this information for one person from the keyboard and print the same on the screen.

#include <stdio.h>
struct personal
{
char name[20];
int day;
char month[10];
int year;
float salary;
};
void main()
{
struct personal person;
printf("Input Values\n");
scanf("%s %d %s %d %f",person.name,&person.day,person.month,&person.year,&person.salary);
printf("%s %d %s %d %f\n",person.name,person.day,person.month,person.year,person.salary);
getch();
}

OUTPUT
Input Values
M.L.Goel  10  January  1945  4500
M.L.Goel  10  January  1945  4500.000000 

No comments:

Post a Comment