Saturday 1 November 2014

In a program declare following structure member: name, code, age, weight and height. Read all members of the structure for 10 persons and find list of persons with all related data whose weight > 50 and height > 40 and print the same with suitable format and title.

No comments :
In a program declare following structure member: name, code, age, weight and height. Read
all members of the structure for 10 persons and find list of persons with all related data
whose weight > 50 and height > 40 and print the same with suitable format and title.



  • BCA-205 : Advanced Programming Language ‘C’
  • Bachelor Of  Computer Application  (BCA)


PRO-18
#include<stdio.h>
#include<conio.h>
struct person
{              char name[20];
                int code,age;
                int hight,weight;
};
void main()
{              int n,i;
                struct person p[10];
                clrscr();
                printf("Enter no.of persons : ");
                scanf("%d",&n);
                for(i=0;i<n;i++)
                {    printf("\n Enter Details of %d persons :",i+1);
                                printf("\n\tName : ");
                                scanf("%s",p[i].name);
                                printf("\n\tcode : ");
                                scanf("%d",&p[i].code);
                                printf("\n\tHight in inch. : ");
                                scanf("%d",&p[i].hight);
                                printf("\n\tWeight in kg. : ");
                                scanf("%d",&p[i].weight);
                }
printf("\n\t\t-::- List of Persons -::- ");
printf("\nList of persons Whose weight > 50 and Height
              > 40");
printf("\n--------------------------------------");
printf("\nName\tCode\tHeight(inch.) Weight(kg.)");
printf("\n-------------------------------------");
for(i=0;i<n;i++)
{              if(p[i].hight>40&&p[i].weight>50)
                {              printf("\n%s\t %d\t %d\t \t%d",
                        p[i].name,p[i].code,p[i].hight,p[i].weight);
}              }
                getch();
}
OUTPUT:
Enter Details of 1 persons :
        Name : abcd
        code : 1
        Hight in inch. : 42
        Weight in kg. : 60
       
Enter Details of 2 persons :
        Name : xyzw
        code : 3
        Hight in inch. : 38
Weight in kg. : 45
Enter Details of 3 persons :
        Name : aaaa
        code : 3
        Hight in inch. : 46
        Weight in kg. : 61
Enter Details of 4 persons :
        Name : bbbb
        code : 4
        Hight in inch. : 38
        Weight in kg. : 49
 Enter Details of 5 persons :
        Name : cccc
        code : 5
        Hight in inch. : 46
        Weight in kg. : 58
 Enter Details of 6 persons :
        Name : dddd
        code : 6
        Hight in inch. :45
        Weight in kg. : 55
        -::- List of Persons -::-
List of persons Whose weight > 50 and Height > 40
-----------------------------------------------------
Name    Code    Height(inch.) Weight(kg.)
------------------------------------------------------
abcd          1             42                     60
aaaa          3             46                     61
cccc           5             46                    58
dddd         6             45                    55

No comments :

Post a Comment