**Statement of C Program:**This Program reads N integers (+ve , -ve and zero) into an Array A and Finds

- The sum of positive numbers
- The sum of negative numbers
- The average of all input numbers.

#include<stdio.h>

#include<conio.h>

**#define MAX 8**

void main()

{

int Array[MAX] ;

int i , N ;

int negsum , posum;

/*

**negsum stands for Sum of Negative Numbers and posum stands for Sum of Positive Numbers***/

clrscr();

negsum = 0 ;

posum = 0;

total = 0;

printf(" Enter the value of N\n");

scanf("%d" , &N);

**printf(" Enter %d numbers( -ve , +ve and 0 )\n" , N);**

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

{

scanf(" %d" , &Array[i] );

}

**printf(" Array elements\n");**

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

{

printf("%d\n" , Array[i] );

}

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

{

**if**(Array[i] < 0)

{

negsum + = Array[i];

}

**else if**(Array[i] > 0)

{

posum + = Array[i] ;

}

**else if**(Array[i] == 0)

{

**;**

}

total + = Array[i];

}

average = total

**/**N;printf(" Sum of all positive numbers =%d\n" , posum);

printf(" Sum of all negative numbers =%d\n" , negsum);

printf(" Average of all input numbers %f\n" , average);

} / *

**End of main()***/ Output:

Enter the value of N

5

Enter 5 numbers (-ve , +ve and 0)

6

-7

0

-3

5

Array elements

6

-7

0

-3

5

Sum of all positive numbers = +11

Sum of all negative numbers = -10

Average of all input numbers = 0.20

**That's All**

Once you replace negative thoughts with positive ones, you'll start having positive results. See the link below for more info.

ReplyDelete#negative

www.matreyastudios.com

Thanks for nice post.C programming details here

ReplyDeleteI just wanna say thank you for sharing the content and wish you all the best for your website and your whole team.

ReplyDeletewww.imarksweb.org

Wow amazing i saw the article with execution models you had posted. It was such informative. Really its a wonderful article. Thank you for sharing and please keep update like this type of article because i want to learn more relevant to this topic.

ReplyDeleteBest Linux training in Noida

Linux Training Institute in Noida

Shell Scripting Training Institute in Noida