How to Write a C program that receives 10 float numbers from the console and sort them in non-ascending order, and prints the result in C Programming Language ?
Solution:
/*C program that receives 10 float numbers from the console and sort them in non-ascending order, and prints the result*/
#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.\n\n");
//print message to enter 10 numbers
printf("enter 10 numbers:(Note:enter one number and press enter)\n");
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:\n %f\n %f\n %f\n %f\n %f\n %f\n %f\n %f\n %f\n
%f\n",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:\n");
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\n %f\n %f\n %f\n %f\n %f\n %f\n %f\n %f\n
%f\n",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\n");
scanf ("%x",&p);
} //end of the program
Learn More :
Ascending Order
print
- PRINT PRIME NUMBERS BETWEEN 1-300 USING BREAK AND CONTINUE IN C
- Write a c program to print Pascal triangle.
- C or C++ Program To Print Prime Number
- C Program print fill zero & mod/div
- C Program to printf & scanf Example
- C Program to Print a String Without Use Semicolon.
- C Program To Input & Print More Than One Words In Single Line
- C Program To Print Alphabets Like {Aa Bb Cc...}
- C Program To Print Alphabets Like {Az By Cx...}
- C Program To Print Lines Of A Paragraph Having More Than 15 Characters
- C Program To Print Prime Numbers Upto The Number You Want
- C Program To Print String In Formatted Output Form
- C Program To Print Sum Of n Digit Number
- C Program To Print Table Horizontally
- C Program To Print Tridiagonal Matrix
- C Program To Print Text Into Uppercase
- Printing ASCII Table with Numbers and corresponding characters
- C Program to print all prime numbers from 1 to 300.
- C program that lets the user choose if he wants to add a item to the shopping list or print it out
- C Program to print table vertically
- Loudness Program: Gets loudness level from user; chooses a response And prints it using logical and operative statements
- Function should print the cartesian coordinates of the struct argument
- C Program Read a char & print next char ( file to file )
- Primul meu program in C Program
Number
- Find out the perfect number using c program
- Write a c program to find out H.C.F. of two numbers.
- Check the given number is armstrong number or not using c program.
- Write a c program to find largest among three numbers using conditional operator
- FIND OUT GENERIC ROOT OF A NUMBER - C PROGRAM.
- FIND PRIME FACTORS OF A NUMBER USING C PROGRAM
- How To Write a C program that generates two random numbers ?
- Write a C program to find maximum or equal between two numbers ?
- How to Write a C program to find maximum between two numbers ?
- Write a C program to perform math operations on two input whole numbers. The operations are:
- Write a C program to find maximum between three numbers ?
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program to Enter an ODD number between 1 and 49.
- C program acquires keyboard 10 numbers for each of these numbers to determine if it is a first issue, by printing immediately message should at the end, if none of the numbers you entered was a first issue, print an appropriate message.
- C program generates a random number and uses an algorithm to generate 9 other numbers.
- C Program to Find Random Number
- C Program To Find LCM and HCF Of Two Number Using Function - 2
- C Program to find LCM and HCF Of Two Number Using Recursion - 3
- C Program To Find LCM and HCF Of Two Number -1
- C Program To Find Reverse Of Any Digit Number
- C Program To Find The Frequency Of A Number
- C Program To Print Prime Numbers Upto The Number You Want
- C Program To Print Sum Of n Digit Number
- C Program To Reverse A Number
- C Program To Search A Number Inside The Array
Receive
Result
- C Program to find result where value and power are user given
- C Program to calculate sum of two m*n matrices & store the result in 3 matrix
- C Program to accept n numbers & store all prime numbers in an array & display this result
- C Program to accept a string from user, delete all vowels from that string & display the result
Console
- How To Write a C program that reads your first and last names and then converts them to upper-case and lower-case letters. The results will be printed to standard output console.
- C Program to Defines the entry point for the console application
- C Program to Defines the entry point for the console application
- Defines the entry point for the console application.
- File Handling (console to file) in C Program
Sort
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program Sort Example
- C Program Shell Sort Using C Programming Language
- C Program Selection Sort Using C Programming Language
- C Program to Bubble Sort Using C Programming Language
- C Program Insertion Sort Using C Programming Language
- Heap Sort Using C Programming Language
- C Program To Sort An Array In Ascending And Descending Order
- C Program To Sort An Array Of Names In Alphabetical And Reverse Order
- C Program Sort Array By Segment
- C Program to sort an array using bubble sort
- C Program to merge and sort two arrays
- Un-sortiertes Array and Sortiertes Array
- matrix sort in C Program
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to accept n numbers from user,store these numbers into an array & sort the number of an array
- C Program to Implement Quick Sort
- QuickVSInsertion Sorting C Program