I've gotten the task in school that is the following:
1: Create an array of 20
2: Add a random number between -50 and 50 to every space in the array
3: Count all the negative numbers generated
4: Print how many negative numbers found
I am pretty sure i got 1 and 2 right. I just dont understand why my program wont count all the negative numbers and print them.
I hope some of you are of some help
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#define Array_SIZE 20
int main ( void )
{
srand( time(0) );
int i, negativeCount=0;
float myArray[ Array_SIZE ];
for( i=0; i<Array_SIZE; i++ ) {
myArray[i] = rand()%-50 + 49;
}
if( myArray[i]<0);
negativeCount++;
printf("Number of negatives:");
scanf("%d", &myArray, &negativeCount);
return (0);
}
Thanks in advance!

New Topic/Question
Reply



MultiQuote




|