Computer Science, asked by aashakaithwas77, 2 months ago

Write a program to find sum of even numbers and odd numbers with algorithm and flowcharts​

Answers

Answered by Riya1045
2

maybe something like this:

n = 101

sum = 101

1 if n = 199 quit

n = n+2

sum = sum + n

go back to 1

quit ---> print the sum and end

Damon

Aug 27, 2016

start

N=N+1,OS=0

N<=200

IfN/2=1

OS=OS+N

N=N+1

Print OS

Stop

Answered by vaishnavi9290
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);

Similar questions