Do Loop (Calculate Sum of even number out of the N numbers input by the user).

#include <stdio.h>

#include <stdlib.h>


int main()

{

   int num,rem,sum,i,n;


   printf("Enter the number of elements : ");

   scanf("%d",&n);

   i = 1;

   sum = 0;

   while ( i <= n) {

        printf("\n Enter the nummber : ",i);

        scanf("%d",&num);

        rem = num % 2;

        if(rem == 0){

            sum = sum + num;

        }


            i= i+1 ;

   }


        printf("Sum is : %d \n",sum);


    return 0;

}


Comments