Computer Science, asked by singharpit8517, 11 months ago

Write a program in photo generate first 20natural numbers

Answers

Answered by koushikreddy2004
0

#include<stdio.h>

#include<conio.h>

 

void main()

{       int i,n,t=0,sum=0;

float avg;

clrscr();

printf("First 20 natural numbers are:\n");

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

{

t+=1;

printf("%3d",t);

sum +=t;

}

avg =sum/20.0;

printf("\n\nThe sum of = %d\n",sum);

printf("\nThe average  of = %8.2f\n",avg);

getch();

}

Similar questions