Quick actions

cmd+k|ctrl+k

Navigation

Languages

n terms of natural

Snippet info

Language

C

Visibility

public

Author

krishnakanth

Created

2023-01-19T15:36:08.028593Z

Updated

2023-01-19T15:36:08.028593Z

/*Exercise-4:
a) write a program in C to display the n terms of even natural number and their sum.
*/
#include <stdio.h>
void main()
{
 int i,n,sum=0;
 printf("Input number of terms : ");
 scanf("%d",&n);
 printf("\nThe even numbers are :");
 for(i=1;i<=n;i++)
 {
 printf("%d ",2*i);
 sum+=2*i;
 }
 printf("\nThe Sum of even Natural Number upto %d terms : %d \n",n,sum);
}
INFO