# Write a program that will accept 20 numbers and will display the average of all positive numbers and all negative number.

Posted by on

• Level 1:

An expert who has achieved level 1.

Corporal:

An expert that hasĀ over 10 points.

Mayor:

An expert whose answer gotĀ voted for 2 times.

Problem Solver:

An expert who has answered 5 questions.

• Contributor

/*The average of all positive numbers and all negative number*/
#include"conio.h"
#include"stdio.h"

main(){
int x[20],sum1=0,sum2=0,ave1,ave2,k=0,p=0,i;

printf("Enter the number");
for(i=0;i<=19;i++)
scanf("%d",&x[i]);

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

if(x[i]<=0) {
k++;
sum1=sum1+x[i];
ave1=sum1/k; }

else {
p++;
sum2=sum2+x[i];
ave2=sum2/p;
}

printf("ave_neg=%d",ave1);
printf("ave_pog=%d",ave2);
getch();
}

Posted on Aug 06, 2013

• Level 1:

An expert who has achieved level 1.

• Contributor

In which language you want?

Posted on Aug 02, 2013

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
Best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
New users get 2 Free calls (no credit card required) and instant help on almost anything you can think of (from cars to computers, appliances, handyman, and even pets).
Goodluck!

Posted on Jan 02, 2017

SOURCE: c++ problem

I guess this can be done quite easily with stl sort function:
http://www.sgi.com/tech/stl/sort.html
You can also code a sorting algorithm like quicksort or bubblesort yourself. This is quite fun!

Posted on Dec 19, 2008

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,rem,prime,primchk=1,chk;
clrscr();
printf("\nEnter the limit\n");
scanf("%d",&n);
printf("\n\n\nThe prime numbers are\n");
printf("\n2\t3\t");
for(primchk=1;primchk<=n;primchk++)
{
for(i=2;i<primchk;i++)
{
if(primchk%i==0)
{
chk=1;
chk=0;
break;
}
if(i==primchk-1)
{
if(chk==0)
{
printf("%d\t",primchk);
chk=0;
}
}
}
}
getch();
}

Posted on May 21, 2009

in the diagram "y" =yes "n" = no

Posted on Oct 08, 2012

×

my-video-file.mp4

×

## Related Questions:

### How many pairs of whole numbers have a sum of 40?

That depends on your definition of "whole numbers."
In the positive integers, there are twenty pairs: (1, 39), (2, 38), ... (20, 20).
If you allow zero, add (0, 40).
If you allow negative numbers, there are an infinite number of pairs:
(-1, 41), (-2, 42), (-3, 43)...

Sep 17, 2014 | The Learning Company Achieve! Math &...

### Write a program c that declares an array of 100 elements to hold these values. Read the values in from the file and store them in successive elements of the array. Keep track of how many numbers are read...

That appears to be an intermediate question in a programming class. Best read the book, the answer is not what is important the process of getting the answer is what you are trying to learn.

May 17, 2017 | Office Equipment & Supplies

### Write a program that accepts two numbers a and b and divides a by b and displays the quotient and the remainder..

BASIC

a = 0
b = 0
c = 0
input "First number "; a
input "Second number "; b
c = int ( a / b )
d = ( a / b ) - c
print "Quotient: "; c
print "Remainder: "; d
end

Dec 11, 2010 | Computers & Internet

### I am having issues performing a simple function on my TI-30XS calculator. when I square a negative number - I get a negative number as opposed to a positive number?? example -3 - which I specify the...

You're not calculating the square of a negative number, you're calculating the negative of a square. You need to use parenthesis to indicate the square of a negative number.

You're calculating -(3^2), not (-3)^2.

To calculate the latter: ( (-) 3 ) x^2 =

Dec 05, 2010 | Texas Instruments TI-30XA Calculator

### How do I get this calculator to substract

Big calculators work a little different than handheld calculators. Like the above commentor explained, if you have a basic "whats 100 minus 20?" You have to entered as 100 + 20 -- And when you hit the minus button at the end, it will give you the total. 100 is the positive number, and the 20 is the negative number that your subtracting. Also you can hit 20 -- 100 + and get the same total because you entering 20 as the negative and 100 as the positive, just in reverse.

Jul 27, 2009 | Casio HR-100TEPlus Calculator

### C# code wite a program to accept a number from the user and display all the prime numbers fro zero up to the numbers entered by user?

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,rem,prime,primchk=1,chk;
clrscr();
printf("\nEnter the limit\n");
scanf("%d",&n);
printf("\n\n\nThe prime numbers are\n");
printf("\n2\t3\t");
for(primchk=1;primchk<=n;primchk++)
{
for(i=2;i<primchk;i++)
{
if(primchk%i==0)
{
chk=1;
chk=0;
break;
}
if(i==primchk-1)
{
if(chk==0)
{
printf("%d\t",primchk);
chk=0;
}
}
}
}
getch();
}

May 20, 2009 | Computers & Internet

### C++ problem

I guess this can be done quite easily with stl sort function:
http://www.sgi.com/tech/stl/sort.html
You can also code a sorting algorithm like quicksort or bubblesort yourself. This is quite fun!

Nov 28, 2008 | Computers & Internet

#### Related Topics:

145 people viewed this question

Level 3 Expert

Level 3 Expert