Computer Science, asked by MugdhaH, 1 year ago

Write a program to print the sum of first N even numbers-​

Answers

Answered by kingsman1342
1

The program output is also shown below.

int i, num, odd_sum = 0, even_sum = 0;

printf("Enter the value of num\n");

scanf("%d", &num);

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

if (i % 2 == 0)

even_sum = even_sum + i;

odd_sum = odd_sum + i;

printf("Sum of all odd numbers = %d\n", odd_sum);


mosam05: where is output
Similar questions