answersLogoWhite

0


Best Answer

#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
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to find sum of odd numbers in an array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
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); }


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]); } }


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 write a c program sum of ODD Numbers in the Given Range?

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


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.


Can you find 3 odd numbers that equals to fifty?

No. An odd plus an odd is even, and an even plus an odd is odd. Thus, you will always end up with an odd number if you add only three odd numbers together, and 50 is even.


How do you find the median in an odd set of numbers?

you cross the numbers out from back to front