How to write a C Program to reads in three Integers and displays them in ascending order in C Programming Language ?
Let's read on the keyboard three integers. Write them out in ascending order!This program reads in three Integers and displays them in ascending order.
Solution For C Program:
/* Olvassunk be a billentyûzetrõl három egész számot. Írjuk ki õket növekvõ sorrendben! */
#include <stdio.h>
int main(){
int a;
int b;
int c;
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
printf("%d %d %d\n\n\n", a, b, c);
if(a==b && a==c ){
printf(" %d %d %d", a, b, c);
return 0;
}
if(a==b){
if(a<c){
printf(" %d %d %d", a, b, c);
}
else
printf(" %d %d %d", c, a, b);
}
if(a==c){
if(a<b){
printf(" %d %d %d", a, c, b);
}
else
printf(" %d %d %d", b, a, a);
}
if(b==c){
if(b<a){
printf(" %d %d %d", b, c, a);
}
else
printf(" %d %d %d", a, b, c);
}
if(a<b && a<c){
if(b<c){
printf(" %d %d %d", a, b,c);
}
if(c<b){
printf(" %d %d %d", a, c, b);
}
}
if(b<a && b<c){
if(a<c){
printf(" %d %d %d", b, a, c);
}
if(c<a){
printf(" %d %d %d", b, c, a);
}
}
if(c<a && c<b){
if(a<b){
printf(" %d %d %d", c, a, b);
}
if(b<a){
printf(" %d %d %d", c, b, a);
}
}
return 0;}
Learn More :
Display
- DISPLAY SOURCE CODE AS OUTPUT IN C PROGRAM
- C Program To Display The Number In A Specific Formats
- C Program that Display a IBM Logo
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- LED ON OFF For One Sec/Count and Display on the Attached Serial Monitor
- Pre Order, Post order, In order Implement Binary Tree using linked list
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C Program to accept n numbers & store all prime numbers in an array & display this result
- C program to display the transpose of given 3 X 3 matrix
- C Program to accept a string from user, delete all vowels from that string & display the result
- C Program To Create Two Singly Linked List and Perform Following Operation
- Create Two Singly Linked List Perform Differences Display It C Program
- C Program to Create, Display, Insert and Deletion of Queue Elements
- Creation and Display of Elements in Both Forward and Reverse Direction in a Doubly Linked List
- C Program to Display a real time clock (HH:MM:SS) on the LCD
- Program to Display Pie Chart Accepting User Input C Program
- Linked List For Getting Employee Details, Display and Search For Salary C Program
- Menu driven program in the creation,display,search, insertion and deletion of a node in the linked list
- Program to display the following pattern in C
- Display the Following Pattern * ** *** **** ***** C Program
Integer
- How to Write a C program to perform basic math operations on two input whole numbers. The basic operations are addition, subtraction, multiplication, integer division, real division, and modulus.
- C program to Given a vector (integer or real), determine what is the maximum value of element what is the position in which this element is located
- C Program Generates 10 Random Integers Between 0 and 99.
- Lower-Upper Case/Positive-Negative Integer
- Give me an integer and I will sum it with the previous natural numbers
- Find the union and intersection of two sets of integer store it in two array C Program
- C Program to Detect int Underflow-Overflow using if-else
- Menu Driven Program to Read Two Integers Find Sum, Difference and Product C Program
Ascending Order
Sort
- 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 that receives 10 float numbers from the console and sort them in non-ascending order, and prints the result
- 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
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 ?
- 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
Read
- C or C++ program to read marks of 4 subjects and find how many students are pass and fail with division
- C Program readers/writers
- C Program to Demonstrates use of reader/writer lock
- C Program to Write/Read Dynamic Data Example
- C Function to read instructions from the file and obey them
- A small I/O bound program to copy N bytes from an input file to an output file.
- Input reads in the array positions and range for random generation.
- C Program to Read and Write FIFO
- pthreads Readers/Writers Lock C Program
- C Program to opens and reads dictionary file specified in spellrc
- C Program reads in and spews out the attributes of a given .wav file.
- C Program Number of Judge and Score From Each Judge
- Read 10 real numbers using a vector and show the least of them C Program
- C Program To Read A Parenthesised Infix Expression From The User And Check Whether It Is Well Parenthesised Or Not
- C Program To Read The Adjecancy Matrix of Directed Graph And Convert It Into Adjecancy List
- C Program Read a char & print next char ( file to file )
- Menu Driven Program to Read Two Integers Find Sum, Difference and Product C Program