Search This Blog

Loading...

Write a program to store 10 numbers in an array. Then find out Sum, Maximum and Average of these 10 numbers : GTU Nov-Dec 2010

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

main()
{
    int number[10], sum=0, i, max = 0;
    float average;

    clrscr();

    for(i=0;i<10;i++)
    {
        printf("Please Enter Number %d : ",i+1);
        scanf("%d",&number[i]);
    }
    printf("\n Sum of all Numbers : ");

    for(i=0;i<10;i++)
    {
        sum += number[i];
    }

    printf("%d",sum);
    printf("\n Average of all Numbers : ");
    average = sum/10;
    printf("%f",average);
    printf("\n Maximum Number is : ");
    for(i=0;i<10;i++)
    {
        if(max < number[i])
            max = number[i];
    }
    printf("%d",max);

    getch();
}

No comments:

Post a Comment