Digital जीवन

Free Online Education for India...

Full width home advertisement

Computer Basic

C Programming

Engineering Graphics

Post Page Advertisement [Top]

Dr. A.P.J. Abdul Kalam Technical University, Lucknow

KCS101 / KCS201 Programming for Problem Solving - Using C Language


Lab Exercises


7. Write a program to find the greatest of the three numbers.


/*
 File: Prgrm07.c
 Author: Aditya Saini
 Date: Sept 18, 2019
 Description: Program to find the greatest of the three numbers.
*/

#include <stdio.h>

int main (void)
{
               int number_1, number_2, number_3;

               //Input numbers.
               printf ("Input first number: ");
               scanf ("%d", &number_1);
               printf ("Input second number: ");
               scanf ("%d", &number_2);
               printf ("Input third number: ");
               scanf ("%d", &number_3);

               //Finding the greatest number and output the result.
               if (number_1 > number_2 && number_1 > number_3)
               {
                              printf ("First number is greatest."); 
               }
               else if (number_2 > number_3)
               {
                              printf ("Second number is greatest.");
               }
               else
               {
                              printf ("Third number is greatest.");
               }

               return 0;
};

Output

Input first number: 25
Input second number: 19
Input third number: 34
Third number is greatest.



No comments:

Post a Comment

Please do not post spam links.

Bottom Ad [Post Page]

| Designed by Colorlib