jituTechnology

jituTechnology

Write a program to read N number of person’s ages in an array and print minimum,maximum and average age

/*program to read N number of person’s ages in an array and print minimum,maximum and average.
programmed by:
Name: JItendra Kumar Yadav
Roll: 10116
Dtae 29 th march 2011 */
#include <stdio.h>
#include <conio.h>
void main ()
{
int i,j,n;
int sum=0;
int max,min;
float avg;
int age[100];
printf(“Enter the number of people “);
scanf (“%d”,&n);
printf(“Enter the age of peoples: “);
for (i=0;i<n;i++)
scanf (“%d”,&age[i]);
max = age[0];
min = age[0];
for (j=0;j<n;j++)
{
if(age[j]>max)
max = age[j];
if (age[j]<min)
min = age[j];
sum=sum+age[j];
}
avg=sum/n;
printf(“the max is %d\n”,max);
printf (“The min is %d\n”,min);
printf(“The average value of age is %f”,avg);
getch ();
}

Add a comment

Comments (1)

  1. Thanks a ton for the good writeup. Mind you, how could we communicate?

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

April 2024
S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930