Write a program in C to read 10 numbers from keyboard and find their sum and average



program


#include <stdio.h>

#include <conio.h>

void main()

{

    int asum = 0;

    float avg;

    printf("enter a value of a: ");

    scanf("%d", &a);

    for (int i = 0i <= ai++)

    {

        sum = sum + i;

        avg = sum / a;
    }

    printf("sum of first %d natural number is  %d \n"asum);

    printf("average of first %d natural number is %.2f \n"aavg);

    getch();
}

OUTPUT
Enter a value of a: 45
The sum of the first 45 natural number is  1035 
The average of the first 45 natural number is 23.00

Follow our page for regular updates.

0 Comments