Question

1. Using the random number program, fill up an array with 100 random numbers between -30 and 30 and display it. Find out how

C languge please !
0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:-

#include <stdio.h>

#include <stdlib.h>

int main(void) {

int arr[100];

int i;

int positive = 0;

int negative=0;

int odds = 0;

int evens=0;

for(i=0;i<100;i++){ // this is the first and only for loop

arr[i] = (rand()%(61)) - 30; //rand() % (upper-lower+1))+lower;

// is used to calculate the random number between 2 numbers

if(arr[i]>0){ // if number is positive

positive++;

}else if(arr[i]<0){ // when number is negative

negative++;

} // special case is when number is zero, then is neither positive nor negative

if(arr[i]%2==0){ //if divisible by 2

evens++;

}

else{ // else

odds++;

}

printf("%i ",arr[i]);

}

printf("\n"); //printing the results

printf("Number of positive numbers are: %i\n",positive);

printf("Number of nehative numbers are: %i\n",negative);

printf("Number of even numbers are: %i\n",evens);

printf("Number of odd numbers are: %i\n",odds);

return 0;

}

main. E saving... 1 #include <stdio.h> 2 #include <stdlib.h> int main(void) { int arr[100]; int i; int positive = 0; int nega

OUTPUT:-

? clang-7 -pthread -lm -o main main.c ./main -1 24 -27 24 -23 19 17 29 -2 -7 -24 17 11 -10 -21 10 22 -11 -6 20 26 15 8 -22 0

FOR ANY OTHER QUERY PLEASE COMMENT! UPVOTE.

Add a comment
Know the answer?
Add Answer to:
C languge please ! 1. Using the random number program, fill up an array with 100...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Task 1 Main Function: Declare and fill an array with 1000 random integers between 1 -...

    Task 1 Main Function: Declare and fill an array with 1000 random integers between 1 - 1000. You will pass the array into functions that will perform operations on the array. Function 1: Create a function that will output all the integers in the array. (Make sure output is clearly formatted. Function 2: Create a Function that will sum and output all the odd numbers in the array. Function 3: Create a Function that will sum and output all the...

  • 7eatng that function Write a C++ program that does the following: Fill an array of 123...

    7eatng that function Write a C++ program that does the following: Fill an array of 123 elements using srand) and rand) with random numbers between 150 and 667. Fill an array of 123 elements with random numbers between 150 and 667. Using a loop. Fill an array of 123 elements with random numbers between 150 and 667. Using a for loop Use a void function to fill an array of 123 elements with random numbers between 150 and 667, Possible...

  • Write an application that does the following: (1) fill a 32-bit array with 10 pseudo-random integers...

    Write an application that does the following: (1) fill a 32-bit array with 10 pseudo-random integers between -50 and +49 ; (2) Loop through the array, displaying each value, and count the number of negative values; (3) After the loop finishes, display the count. Below is an assembly program template that you can refer, and complete the programming by filling in the codes into the specified place: Comment ! Title: Counting Array Values Description: Write an application that does the...

  • In C language 1. Write a program to declare and initialize an array of size 5...

    In C language 1. Write a program to declare and initialize an array of size 5 and place odd numbers 3, 5, 7,9 and 11 in it. Declare and initialize another array of size 5 and place even numbers 4, 6, 8, 10 and 12 in it. Write a for loop to add each element and place it in a third array of the same dimensions. Display each array.

  • Write a program that check odd / even numbers (from number 1 to 100). Display the...

    Write a program that check odd / even numbers (from number 1 to 100). Display the results within an HTML table with 2 columns: one for odd number and one for even numbers. NUMBERS RESULTS ODD EVEN ODD 2 HINT: use <table> tags to create a table, <th> tags for 'Numbers' and 'Results'. Wrap code PHP inside HTML code. For example: <html> <title>CHECK ODD or EVEN</title> <body> <table> ?php echo "<tr><td>l</td><td>Odd</td</tr>"; </table> </body </html 2. Do the following steps in...

  • C langauge Please. Complete all of this please. Thanks :) Statistical Analysis Write a program that...

    C langauge Please. Complete all of this please. Thanks :) Statistical Analysis Write a program that creates an array of 10 integers. The program should then use the following functions: getData() Used to ask the user for the numbers and store them into an array displayData() Used to display the data in the array displayLargest() Used to find and display the largest number in the array (prior to sort). displaySmallest() Used to find and display the smallest number in the...

  • Write a C++ program that will create an array with a given number of elements. Use...

    Write a C++ program that will create an array with a given number of elements. Use size = 10 for demonstration purposes, but write the program where the size of the array can be changed by changing the value of one constant. Fill the array with random numbers between 0 and 100. Write the program to perform the following operations: 1. Find and display the largest value in the array. 2. Find and display the smallest value in the array....

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • PLEASE SOLVE USING BASIC C++ CODEING PRINCIPLES PLEASE USE BASIC ARRAY, FUNCTION, AND LOOPING PRINCIPLES PLEASE...

    PLEASE SOLVE USING BASIC C++ CODEING PRINCIPLES PLEASE USE BASIC ARRAY, FUNCTION, AND LOOPING PRINCIPLES PLEASE COMPLETE ALL ASPECTS OF PAPER THANK YOU!!! Objectives To learn to code, compile and run a program containing ARRAYS. . Assignment Plan and code a modular program utilizing arrays. Use at least three functions to solve the problem. Input numbers from a textfile. Input the numbers, one by one. Store the even numbers in one array. Store the odd numbers in a second array....

  • C++ Code: PLEASE MAKE SURE THAT IS WORK -input any number between (0-100) • if the...

    C++ Code: PLEASE MAKE SURE THAT IS WORK -input any number between (0-100) • if the number is odd, the program ends (do nothing) • if the number is even, output all the even numbers to 100 above the input Requirements: use if statements (minimum 1), and minimum 1 loop

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT