Structure programming in c

Develop a C program to create a structure emp with the members : name ,age & address .take 10 values through keyboard and detailed information about employees in tabular format . Also display the name of the employees whose age is more than 20.

#include<stdio.h>
#include<conio.h>
struct employee
{
               char name[20],address[100];
               int age;
       };
       int main()
       {
               struct employee emp[10];
  int i;
               for(i=0;i<10;i++)
               {
                       
                             printf(“ENter the name of the employee: “);
                               fflush(stdin);
                               gets(emp[i].name);
                               printf(“Enter the address: “);
               fflush(stdin);
                               gets(emp[i].address);
                               printf(“Age: “);
                               scanf(“%d”,&emp[i].age);
               }
              
               for(i=0;i<10;i++)
         {
                      printf(“\n%s\t%s\t%d\n”,emp[i].name,emp[i].address,emp[i].age);
            }
     for(i=0;i<10;i++)
         {
     if(emp[i].age>20)
             printf(” \n\n\nname of the employees whose age is more than 20 are : “);
             printf(“\n%s\t%s\t%d\n”,emp[i].name,emp[i].address,emp[i].age);
            }

               
               
               getch();
       }

OUTPUT

Enter the name of the employee: RAM
Enter the address: MUMBAI
Age: 18
Enter the name of the employeet: SHAM
Enter the address: DELHI
Age:    
Enter the name of the employee: MADHU
Enter the address: KOLKATA
22
………………………………………………………….
………………………………………………………….
…………………………………………………………
RAM                MUMBAI           18
SHAM             DELHI              21
MADHU           KOLKATA       22       
…………………………………………………………
………………………………………………………….
………………………………………………………….
…………………………………………………………
name of the employees whose age is more than 20 are :
SHAM             DELHI              21
MADHU           KOLKATA       22    
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s