PLEASE USE JUST BASIC COMPILER ONLY : NO JAVA OR C++ CODE!! Write a program to a
ID: 3758781 • Letter: P
Question
PLEASE USE JUST BASIC COMPILER ONLY : NO JAVA OR C++ CODE!!
Write a program to ask the user as to how many numbers they want to enter.
your program should collect that many numbers from the user and find the smallest and Average of those numbers.
For example, if the user says, he/she wants to enter 6 numbers, you should collect 6 numbers. You can accomplish this by looping 6 times, collecting one number each time you are in the loop.
Hint 1: You can use the while..wend loop to write this program
Hint 2: Study the program which calculates the largest of the 10 numbers.
Explanation / Answer
#include <stdio.h>
int main() //Program Start
{
float numbers[10],result; //definition of float variables and numbers[10] is a array
int i,p,k; //definition of integer variables
printf("The program take 10 float numbers and organize in decreasing order. ");
//print message to enter 10 numbers
printf("enter 10 numbers:(Note:enter one number and press enter) ");
for(i=0;i<10;i++) //loop for input
scanf("%f",&numbers[i]); //the input numbers are save in numbers[i]
//print message of the numbers the user enter
printf("Numbers that you enter are: %f %f %f %f %f %f %f %f %f
%f ",numbers[0],numbers[1],numbers[2],numbers[3],numbers[4],numbers[5],numbers[6],numbers[7],
numbers[8],numbers[9]);
//print a message of the numbers in decreasing order
printf("decreasing order: ");
for(i=10;i>=0;i--) //loop for compare the numbers enter
{ for(k=10;k>=0;k--) //loop for compare the numbers with the array numbers[k]
{ if(numbers[i]<numbers[k]) //compare
{
result=numbers[i]; //save number
numbers[i]=numbers[k]; //save the greater number one after another
numbers[k]=result; } } }
//print the numbers in decreasing number
printf(" %f %f %f %f %f %f %f %f %f
%f ",numbers[0],numbers[1],numbers[2],numbers[3],numbers[4],numbers[5],numbers[6],numbers[7],
numbers[8],numbers[9]);
// Message to exit the program
printf ("Press any botton and enter ");
scanf ("%x",&p);
} //end of the program
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.