Computer Science, asked by sivakumarsivakumar82, 9 months ago

Program to input some numbers repeatedly and print their sum using for loop

Answers

Answered by Karthikrikky12
1

HELLO MATE

#include <stdio.h>

void main()

{

int i,n,sum=0;

float avg;

printf("Input the 10 numbers : \n");

for (i=1;i<=10;i++)

{

printf("Number-%d :",i);

scanf("%d",&n);

sum +=n;

}

avg=sum/10.0;

printf("The sum of 10 no is : %d\nThe Average is : %f\n",sum,avg);

}

OUTPUT:

Input the 10 numbers :

Number-1 :1

Number-2 :2

Number-3 :3

Number-4 :4

Number-5 :5

Number-6 :6

Number-7 :7

Number-8 :8

Number-9 :9

Number-10 :10

The sum of 10 no is : 55

The Average is : 5.500000

HOPE THIS HELPS YOU

PLEASE FOLLOW ME ✌️

MARK ME AS BRAINLIST

Answered by rnmandal6730
1

Answer:In q basic we can do this by the input 1 no. but looping up to 1 to the input no.

Explanation:

cls

input"Enter the number from 1 to n";n

Sum=0

For I=1 to n

Sum=I+Sum

Print Sum

Next I

end

Similar questions