Header Ads Widget

C Program to find the maximum between two numbers by using the switch statement

 C  Program to find the maximum between two numbers by using the switch statement

Given two numbers , write a program to find the maximum between both by using switch statement . 

Sample input

17 10 

Sample output

17 number is greater

 C  Program to find the maximum between two numbers by using the switch statement

The objective of the code is find the maximum between two numbers by using switch case .

Code(C):-

#include<stdio.h>
int main()
{
int a,b;
printf("Enter the numbers ");
scanf("%d%d",&a,&b);
int ch=a>b;
switch(ch)
{
case 1:printf("%d number is greater ",a);
break;
case 0:printf("%d number is greater",b);
break;
}
}


Output:-

Enter the numbers
17 10
17 number is greater


Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

Post a Comment

0 Comments