Q1. Write a program to accept any 10 numbers and find out and print:
sum of positive Numbers
sum of negative Numbers
please answer correctly all the incorrect answer will be reported
Answers
Answer:
Input : arr = {1, 2, 3, 4, 5, 6}
Output :Even index positions sum 9
Odd index positions sum 12
Explanation: Here, n = 6 so there will be 3 even
index positions and 3 odd index positions in an array
Even = 1 + 3 + 5 = 9
Odd = 2 + 4 + 6 = 12
Input : arr = {10, 20, 30, 40, 50, 60, 70}
Output : Even index positions sum 160
Odd index positions sum 170
Explanation: Here, n = 7 so there will be 3 odd
index positions and 4 even index positions in an array
Even = 10 + 30 + 50 + 70 = 160
Odd = 20 + 40 + 60 = 120
Answer:
C Exercises: Read 10 numbers and find their sum and average
C Exercises: Read 10 numbers and find their sum and averagePictorial Presentation:
C Exercises: Read 10 numbers and find their sum and averagePictorial Presentation:Sample Solution:
C Exercises: Read 10 numbers and find their sum and averagePictorial Presentation:Sample Solution:C Code: #include <stdio.h> void main() { int i,n,sum=0; float avg; printf("Input the 10 numbers : \n"); for (i=1;i<=10;i++) { printf("Number-%d :",i); scanf("%d",&n); sum +=n; } avg=sum/10.0; printf("The sum of 10 no is : %d\nThe Average is : %f\n",sum,avg); }