answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

void main()

{

int n, a[10, evensum=0, oddsum=0, i;

printf("\n Enter the number of values");

scanf("\n %d", &n);

printf("\n Enter %d number of values", n);

for(i=0; i<n; i++)

scanf("\n %d", &a[i]);

while(i<n)

{

if(a[i]%2==0)

evensum=evensum + a[i];

else

oddsum=oddsum + a[i];

}

printf("\n Odd sum = %d", oddsum);

printf("\n Even sum = %d", evensum);

getch();

}

Hopefully, is that correct, anyone out there.... I am a beginner and this is my homework, please help me correct the mistaks if you know them...

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Write a java program to find sum of even and odd numbers in given array?

for(int i = 1; i &lt; 100; i+=2) { System.out.println(i); }


What is the process to find the median of an array of numbers?

To find the median of an array of numbers, first, arrange the numbers in ascending order. If the array has an odd number of elements, the median is the middle number. If the array has an even number of elements, the median is the average of the two middle numbers.


How can you separate odd and even numbers from the array of 10 numbers in 8085 microprocessor?

To separate odd and even numbers from an array of 10 numbers in the 8085 microprocessor, you can utilize a loop and the AND instruction. First, load each number from the array into a register and perform a bitwise AND operation with the value 1. If the result is 0, the number is even; if the result is 1, the number is odd. You can then store the odd numbers in one memory location and the even numbers in another, iterating through the entire array until all numbers are processed.


How do you wwrite a Program that prints all odd and even numbers from an array?

void f (int* a, int len) { if (!a) return;for (int i=0; i&lt;len; ++i) { if (a[i]%2) { printf ("%d is odd\n", a[i]); } else { printf ("%d is even\n", a[i]); } }


How do you write a c program sum of ODD Numbers in the Given Range?

Reference: cprogramming-bd.com/c_page4.aspx#ODD%20 Numbers


Can you help me with the C plus plus code of the program which has 10 index of array it adds 5 into every even elements of the array and then it subtracts 10 into the odd elements of the array?

int array[10] = {...}; for (int i = 0; i &lt; 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }


How Do You Find The Square Root of Odd Numbers?

The procedure is the same whether the number is even or odd. There is no separate procedure for odd numbers.


How do you find an odd factor of a number?

All nonzero numbers have factors. Some factors are odd numbers. 3 is an odd factor of 12.


How do you find odd square root?

Look for odd squares. Multiplying odd numbers results in an odd product.


Write a C Program to print sum of squares of odd numbers?

#include


What do you notice when you find the difference between an odd and even numbers?

The answer is an odd number.


Shell program to find the sum of cube of individual digits of a number?

Shell problems are programs that can be run to find out information about numbers. The problem can help find an even or odd number, or what the sum of a cube is.