Question

Implement and test a parallel program that sum only the odd numbers of an array using...

Implement and test a parallel program that sum only the odd numbers of an array using c programming

0 0
Add a comment Improve this question Transcribed image text
Answer #1


#include <stdio.h>

int main()
{
  
int arr[50],i,n,sum=0;
printf("Enter number of elements in array: ");
//Enter no.of elements in the array
scanf("%d",&n);
printf("Enter the elements:\n");
//loop to get array elements from user
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
//for odd numbers,if we divide the number by 2
//It gives reminder 1.
if(arr[i]%2 ==1)
{
//calculate the sum of odd numbers
sum = sum + arr[i];
}
}
//Displays the sum of odd numbers
printf("Sum of odd numbers: %d",sum);
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Implement and test a parallel program that sum only the odd numbers of an array using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT