Question

WRITE A PROGRAM IN C THAT DOES THE FOLLOWING: The numbers are real numbers, read in...

WRITE A PROGRAM IN C THAT DOES THE FOLLOWING:

The numbers are real numbers, read in as double precision floating-point numbers, one number perline, possibly with some white space before or after. Hint: use scanf. There are guaranteed to be no more than one million (that’s 10^6) numbers in the input, and no fewer than two legitimate numbers. Any number that is equal to zero should be ignored (discarded, not stored in the array or counted in any way).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

int main()
{
//array declaration
double arr[1000000], temp;
  
//display message
//enter 10 times 9 for exit
printf("Enter an array of real numbers (enter 9999999999 for exit): \n");
  
//input array element
for(long i = 0; i < 1000000; i++)
{
//input element
scanf("%lf",&temp);
  
//check if exit code
if(i > 1 && temp == 9999999999)
{
//break statement
break;
}
  
//ignore the zero
if(temp != 0)
{
arr[i] = temp;
}
else
{
i--;
}
}
return 0;
}

INPUT:

Enter an array of real numbers (enter 9999999999 for exit): 10.50 20.25 30.00 10.90 30.20

Add a comment
Know the answer?
Add Answer to:
WRITE A PROGRAM IN C THAT DOES THE FOLLOWING: The numbers are real numbers, read in...
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
  • In C code prompt and read from the user an integer number, 'N', of double precision...

    In C code prompt and read from the user an integer number, 'N', of double precision floating point numbers to allocate for the purpose of the current test run. Dynamically allocate an array of N double precision floating point numbers; i.e. the array will require "N*sizeof(double)" bytes of RAM for storage, call this M.

  • Arrays and reading from a file USE C++ to write a program that will read a...

    Arrays and reading from a file USE C++ to write a program that will read a file containing floating point numbers, store the numbers into an array, count how many numbers were in the file, then output the numbers in reverse order. The program should only use one array and that array should not be changed after the numbers have been read. You should assume that the file does not contain more than 100 floating point numbers. The file name...

  • Write a C program to read a counter, and then, read real numbers based on the...

    Write a C program to read a counter, and then, read real numbers based on the value of counter (the number must range from 0.0 to 100.0). Keep all the number entered into an array, and find the biggest, smallest and the middle number. Use void find_biggest_smallest() function to receive the array, and return biggest and smallest number. Let say biggest and smallest is 14 and 2. Therefore average = (14+2)/2 = 8. The middle number is the number which...

  • write a program that will read a file containing floating point numbers, store the numbers into...

    write a program that will read a file containing floating point numbers, store the numbers into an array, count how many numbers were in the file, then output the numbers in reverse order. Your program should only use one array and that array should not be changed after the numbers have been read. You should assume that the file does not contain more than 100 floating point numbers. Numbers found in file 100.7362 105.2896 66.3493 105.6688 91.6180 64.8770 73.9249 87.3441...

  • Write a C PROGRAM that will read in 10 floating-point numbers from the keyboard and load...

    Write a C PROGRAM that will read in 10 floating-point numbers from the keyboard and load them into an array. Add up all the values and store the answer in a variable. Find the largest and smallest number in the array. Put each into its own variable. Print to the screen the sum, largest value, and smallest value. Copy the array to a second array in reverse order. Print out the second array. Read in 20 integer numbers, all in...

  • WRITE A PROGRAM IN C THAT DOES THE FOLLOWING Read a floating point number without using...

    WRITE A PROGRAM IN C THAT DOES THE FOLLOWING Read a floating point number without using scanf or conversion functions from the C library. You would need to write a utility function that processes console input using only getc and/or getchar and flow of control logic to process character-based input from the console to process the input.

  • IN C language Write a C program that prompts the user to enter a line of...

    IN C language Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr andcreadLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate...

  • C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an...

    C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an array of numbers and produce the following output: 1. Your first and last name 2. Course Number 3. C Project Number 4. All the numbers in the array 5. The sum of all the numbers in the array 6. The count of all the numbers in the array 7. The average of all the numbers in the array Double-space after lines 3, 4, 5,...

  • c++ no pointers just follow instructions Write a program (array.cpp) that read positive floating point numbers...

    c++ no pointers just follow instructions Write a program (array.cpp) that read positive floating point numbers into an array of capacity 100. The program will then ask for one of three letters(A, M or S). if the user inputs something other than one of these letters, then the program should ask for that input until an A, M, or S is entered. A do-while loop should be used for this. If the user inputs an A, then the program should...

  • CSE/EEE230 Assignment11 Due Date Thursday, April 25th, 5pm Note: the lowest scored assignment wil...

    CSE/EEE230 Assignment11 Due Date Thursday, April 25th, 5pm Note: the lowest scored assignment will be dropped. Important: This is an individual assignment. Please do not collaborate. It must be submitted on-line (Blackboard). No late assignment will be accepted Minimal Submitted Files You are required to turn in the following source file: assignment11.s Objectives: -write assembly language programs to:             -perform arithmetic on floating point numbers             -use syscall operations to display floating point numbers and strings on the console window             -use syscall...

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