Question

Write a program that will create an array of 10 floating point numbers and take input 10 floats from keyboard. The program wi

Answer should be in C programming language

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

Source code:

#include<stdio.h> /*main function*/ int main() { /*declare float array of size 10*/ float array[10]; /*variables*/ int i,maxp} else { /*check for maximum*/ if(array[i]>maximum) { /*assign maximum*/ /*assign position of maximum*/ maxpos=i; maximum=arr/*print positions of maximum and minimum number*/ printf(The position of the maximum number is: %d, maxpos); printf(\nThe

Output: (Index/position starts from 0 )

C:\Users\Kumar Reddi\Desktop\floatarray.exe Enter 10 floating point numbers: 14.5 9.8 4.7 7.8 8.4 3.7 1.4 3.7 9.8 6.8 The pos

Code in text format:

#include<stdio.h>
/*main function*/
int main()
{
   /*declare float array of size 10*/
   float array[10];
   /*variables*/
   int i,maxpos,minpos;
float maximum,minimum;
/*read 10 floating point numbers from user*/
printf("Enter 10 floating point numbers:\n");
for(i=0;i<10;i++)
{
   /*read element*/
   scanf("%f",&array[i]);
   if(i==0)
   {
       /*assign maximum and minimum*/
       /*assign positions of maximum and minimum*/
       maximum=array[i];
       maxpos=i;
       minpos=i;
           minimum=array[i];  
       }
       else
       {
           /*check for maximum*/
           if(array[i]>maximum)
           {
               /*assign maximum*/
           /*assign position of maximum*/
               maxpos=i;
               maximum=array[i];              
           }
           /*check for minimum*/
           else if(array[i]<minimum)
           {
               /*assign minimum*/
           /*assign position of minimum*/
               minpos=i;
               minimum=array[i];
           }
       }  
   }
   /*print positions of maximum and minimum number*/
   printf("The position of the maximum number is: %d",maxpos);
   printf("\nThe position of the minimum number is: %d",minpos);
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Answer should be in C programming language Write a program that will create an array of...
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
  • write a java program Accept a positive integer n from keyboard and then create an array...

    write a java program Accept a positive integer n from keyboard and then create an array or arraylist containing n random elements within the range [-n,n). Print out the random array or arraylist, and then find out and print out the number of inversions and the maximum subarray (index range of the maximum subarray along with the maximum subarray sum) in the array or arraylist using divide and conquer, respectively. For example, suppose we accept integer 6 from keyboard, then...

  • Language is C programming Student ID should be 8 numbers long. create a program to read...

    Language is C programming Student ID should be 8 numbers long. create a program to read your student ID number and store it in an array. Input can not be hard wired, I have to be able to input my number Then change the first number to a letter. If the same number repeats in other parts of your student ID, you must change that number to a letter as well. print original array and modified array as your output....

  • C programming language 1. Write a program that prints the minimum value and the maximum value...

    C programming language 1. Write a program that prints the minimum value and the maximum value of a given array. For example array a is: int al 10] 140,30,20,50,10,80,99.90,85,70;: the minimum value is 10 and the maximum value is 99. Write a program that Converts an Integer from base 10 to base 2. 2. 3. Write a program that reads in ten marks and then calculates the pass rate

  • in C language Write a program to find the element of an array, which occurs maximum...

    in C language Write a program to find the element of an array, which occurs maximum number of times and its count. The program should accept the array elements as input from the user and print out the most occurring element along with its count. Hint: array size is 5. For example: Enter array elements (array size 5): 22321 Output: Max occurring element: 2. count: 3

  • C++ This week, you are to create two separate programs, first using a simple array and...

    C++ This week, you are to create two separate programs, first using a simple array and the second using a 2D-array (matrix). [Part 1] Write a program that accepts exactly ten (10) integer numbers from the user and stores them in an array. In a separate for-loop, the program then goes through the elements in the array to print back: (i) The sum of the 10 numbers, (ii) the minimum value from the 10 numbers, and (iii) the maximum value...

  • In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • THE PROGRAMMING LANGUAGE IS C++ Part 1.Create a program that decides whether a given integer is...

    THE PROGRAMMING LANGUAGE IS C++ Part 1.Create a program that decides whether a given integer is prime or not. The program should at the end of its analysis print the number followed by prime or composite. Part 2.Make the program from part 1 print the prime factors of any composite number entered (an additional feature to Part 1). THE PROGRAMMING LANGUAGE IS C++

  • Please complete this code for java Lab Write a program as follows: Create an array with...

    Please complete this code for java Lab Write a program as follows: Create an array with 10 elements. The array should contain numbers generated randomly between 1 and 100 Ask the user to enter any number - Search the array to see if the user entered number is in the array If the user-entered number is in the array, print a 'match found' message. Also print at which index the match was found, else print a 'match not found' message...

  • it's in C programming language 3. Write a program to find out if the first two...

    it's in C programming language 3. Write a program to find out if the first two bits of an input hex number is 11and will print "the first two bits are ones" 4- Write a program that will perform the following: Check the first two numbers of an input data if they are 11 and will print "open door 1" if so, otherwise Check the last two bits of that number if they are 11 and print" Open door 2...

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