Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to read person details and display records whose weight is greater than 60 using structure

Posted By: Boell Fischer     Category: C Programming     Views: 8471

Program to read person details and display records whose weight is greater than 60 using structure.

Code for Program to read person details and display records whose weight is greater than 60 using structure in C Programming

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

#define size 3

struct
{
    char nm[20],cd;
    int height,age,weight;
}s[size];

int main()
{
    int i;
    clrscr();
    for(i=0;i<size;i++)
    {
        printf("For person %d\n",i+1);

        printf("Enter the name : ");
        fflush(stdin);
        gets(s[i].nm);

        printf("Enter the code : ");
        flushall(.);
        s[i].cd=getc(stdin);

        printf("Enter the age : ");
        fflush(stdin);
        scanf("%d",&s[i].age);
        printf("Enter the weight : ");
        fflush(stdin);
        scanf("%d",&s[i].weight);
        printf("Enter the height : ");
        fflush(stdin);
        scanf("%d",&s[i].height);
    }
    printf("\n\nPersons having weight greater than 60\n");
    printf("\nName      Code Age Height Weight\n");
    printf("--------------------------------\n");
    for(i=0;i<size;i++)
    {
        if(s[i].weight>60)
        printf("%-10s%-5c%3d%7d%7d\n", 
s[i].nm,s[i].cd,s[i].age,s[i].height,s[i].weight);
    }
    getch();
    return 0;
}



Output:

For person 1
Enter the name : Mikki
Enter the code : M
Enter the age : 23
Enter the weight : 62
Enter the height : 150
For person 2
Enter the name : Mehul
Enter the code : R
Enter the age : 22
Enter the weight : 42
Enter the height : 45
For person 3
Enter the name : Mona
Enter the code : S
Enter the age : 21
Enter the weight : 55
Enter the height : 35


Persons having weight greater than 60

Name      Code Age Height Weight
--------------------------------
Mikki     M     23    150     62
  
Share: 



Boell Fischer
Boell Fischer author of Program to read person details and display records whose weight is greater than 60 using structure is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!