Sunday 9 March 2014

WRITE A PROGRAM TO READ AGE OF N PERSONS AND DISPLAY ONLY THOSE PERSONS WHOSE BETWEEN 50 AND 60.

Code for PROGRAM TO READ AGE OF N PERSONS AND DISPLAY ONLY THOSE PERSONS WHOSE BETWEEN 50 AND 60 in C Programming

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

void main()
{
    int i,n,age[100],count=0;

    clrscr();

    printf("Enter the number of persons  ::  ");
    scanf("%d",&n);

    for (i=1;i<=n;i++)
    {
        printf("\nEnter age of %d persons :: ",i);
        scanf("%d",&age[i]);
    }

    for (i=1;i<=n;i++)
    {
        if(age[i]>50 && age[i] < 60)
        count++;
        elsecontinue;
    }

    printf("\n\nNumber of persons whose age between 50-60 are :: %d",count);
    getch();
}


/*
    **********
    OUTPUT
    **********

    Enter the number of persons  ::  6

    Enter age of 1 persons :: 10

    Enter age of 2 persons :: 20

    Enter age of 3 persons :: 30

    Enter age of 4 persons :: 55

    Enter age of 5 persons :: 51

    Enter age of 6 persons :: 56


    Number of persons whose age between 50-60 are :: 3

No comments:

Post a Comment