Computer Science, asked by arshiad09, 2 months ago

Write a program to find the sum of first 10 even and odd numbers separately.​

Answers

Answered by nitashreetalukdar
7

Answer:

The program output is also shown below.

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

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

)scanf("%d", &num);

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

5) if (i % 2 == 0)

6) even_sum = even_sum + i;

7) odd_sum = odd_sum + i;

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

Similar questions