answersLogoWhite

0


Best Answer

It's not pretty (because I've never written anything in C before but it worked nonetheless) but here you go. I compiled with Microsoft Visual C++ 2010 Express with a Win32 Console Application and this is everything that was written. It worked but looks kind of bulky. Tweak to your heart's content. I wasn't 100% sure what you wanted so I made three versions that do basically the same thing with slight alterations. I learned to code in C for you...

This one lists each one that was either positive or negative.

// snfp.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include "stdio.h"

int

main (void)

{

/* declarations */

double x0=0, x1=0, x2=0, x3=0, x4=0, x5=0, x6=0, x7=0, x8=0, x9=0, y0=0, y1=0, y2=0, y3=0, y4=0, y5=0, y6=0, y7=0, y8=0, y9=0, z0=0, z1=0, z2=0, z3=0, z4=0, z5=0, z6=0, z7=0, z8=0, z9=0;

/* executable statements */

printf ("Enter ten real numbers: ");

scanf ("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", &x0, &x1, &x2, &x3, &x4, &x5, &x6, &x7, &x8, &x9);

if(x0<0){ y0 = x0;}

if(x0>0){ z0 = x0;}

if(x1<0){ y1 = x1;}

if(x1>0){ z1 = x1;}

if(x2<0){ y2 = x2;}

if(x2>0){ z2 = x2;}

if(x3<0){ y3 = x3;}

if(x3>0){ z3 = x3;}

if(x4<0){ y4 = x4;}

if(x4>0){ z4 = x4;}

if(x5<0){ y5 = x5;}

if(x5>0){ z5 = x5;}

if(x6<0){ y6 = x6;}

if(x6>0){ z6 = x6;}

if(x7<0){ y7 = x7;}

if(x7>0){ z7 = x7;}

if(x8<0){ y8 = x8;}

if(x8>0){ z8 = x8;}

if(x9<0){ y9 = x9;}

if(x9>0){ z9 = x9;}

printf ("\nThe negative numbers are %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf.\n", y0, y1, y2, y3, y4, y5, y6, y7, y8, y9);

printf ("\nThe positive number are %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf.\n", z0, z1, z2, z3, z4, z5, z6, z7, z8, z9);

printf ("Type something to exit");

scanf ("%lf", &x0);

return (0);

}

This one tells you how many were positive and how many were negative.

// snfp.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include "stdio.h"

int

main (void)

{

/* declarations */

double x0=0, x1=0, x2=0, x3=0, x4=0, x5=0, x6=0, x7=0, x8=0, x9=0, y0=0, y1=0, y2=0, y3=0, y4=0, y5=0, y6=0, y7=0, y8=0, y9=0, z0=0, z1=0, z2=0, z3=0, z4=0, z5=0, z6=0, z7=0, z8=0, z9=0, neg=0, pos=0;

/* executable statements */

printf ("Enter ten real numbers: ");

scanf ("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", &x0, &x1, &x2, &x3, &x4, &x5, &x6, &x7, &x8, &x9);

if(x0<0){ y0 = 1;}

if(x0>0){ z0 = 1;}

if(x1<0){ y1 = 1;}

if(x1>0){ z1 = 1;}

if(x2<0){ y2 = 1;}

if(x2>0){ z2 = 1;}

if(x3<0){ y3 = 1;}

if(x3>0){ z3 = 1;}

if(x4<0){ y4 = 1;}

if(x4>0){ z4 = 1;}

if(x5<0){ y5 = 1;}

if(x5>0){ z5 = 1;}

if(x6<0){ y6 = 1;}

if(x6>0){ z6 = 1;}

if(x7<0){ y7 = 1;}

if(x7>0){ z7 = 1;}

if(x8<0){ y8 = 1;}

if(x8>0){ z8 = 1;}

if(x9<0){ y9 = 1;}

if(x9>0){ z9 = 1;}

neg = y0 + y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8 + y9;

pos = z0 + z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8 + z9;

printf ("\nThere are %lf negative numbers.\n", neg);

printf ("\nThere are %lf positive numbers.\n", pos);

printf ("Type something to exit");

scanf ("%lf", &x0);

return (0);

}

This one sums the positive and then sums the negative.

// snfp.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include "stdio.h"

int

main (void)

{

/* declarations */

double x0=0, x1=0, x2=0, x3=0, x4=0, x5=0, x6=0, x7=0, x8=0, x9=0, y0=0, y1=0, y2=0, y3=0, y4=0, y5=0, y6=0, y7=0, y8=0, y9=0, z0=0, z1=0, z2=0, z3=0, z4=0, z5=0, z6=0, z7=0, z8=0, z9=0, neg=0, pos=0;

/* executable statements */

printf ("Enter ten real numbers: ");

scanf ("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", &x0, &x1, &x2, &x3, &x4, &x5, &x6, &x7, &x8, &x9);

if(x0<0){ y0 = x0;}

if(x0>0){ z0 = x0;}

if(x1<0){ y1 = x1;}

if(x1>0){ z1 = x1;}

if(x2<0){ y2 = x2;}

if(x2>0){ z2 = x2;}

if(x3<0){ y3 = x3;}

if(x3>0){ z3 = x3;}

if(x4<0){ y4 = x4;}

if(x4>0){ z4 = x4;}

if(x5<0){ y5 = x5;}

if(x5>0){ z5 = x5;}

if(x6<0){ y6 = x6;}

if(x6>0){ z6 = x6;}

if(x7<0){ y7 = x7;}

if(x7>0){ z7 = x7;}

if(x8<0){ y8 = x8;}

if(x8>0){ z8 = x8;}

if(x9<0){ y9 = x9;}

if(x9>0){ z9 = x9;}

neg = y0 + y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8 + y9;

pos = z0 + z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8 + z9;

printf ("\nThe negative numbers add up to %lf.\n", neg);

printf ("\nThe positive number add up to %lf.\n", pos);

printf ("Type something to exit");

scanf ("%lf", &x0);

return (0);

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you write a program in c that will allow the user to input ten numbers and display the total number of positive and negative numbers entered?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the relationship between neggative positive and positive negative?

Negative number and positive numbers are all numbers. Negative numbers are just positive numbers multiplied by -1.


When multiplying numbers what do you do with the positive and negative signs?

Negative * positive = negative Positive * positive = positive Negative * negative = positive


What is the sign of the product of 47 negative numbers and three positive numbers?

Negative because product of 47 negative numbers is negative and product of three positive number is Positive , so negative*positive = Negative.


Is the product of 33 negative numbers and 2 positive numbers a positive number or a negative number?

(The product of 33 negative numbers) x (2 positive numbers) = (negative sign) x (positive sign) = negative sign


Is the product of positive numbers and 7 negative numbers a positive number or a negative number?

negative


Is the product of 7 positive numbers and 6 negative numbers a positive or negative number?

positive


What are the rules for multiplying integers?

Positive x Positive =Positive Positive x Negative= Negative Negative x Positive= Negative Negative x Negative =Positive


Why are negative numbers in brackets positive but positive numbers in brackets are not negative?

'cuz


What is the product of two negative and three positive numbers?

It is positive. Any product of an even number of negative numbers will be positive, regardless of how many positive numbers you have. Similarly any product of an odd number of negative numbers will be negative, regardless of how many positive numbers you have.


Are positive and negative numbers integers?

yes integers are all numbers negative and positive


Are negative numbers bigger or positive?

Positive numbers are larger than negative ones.


Where can you find positive and negative numbers in your house?

Positive numbers, on your door. Negative in your freezer.