Wednesday, 22 June 2016

Program in C to find greatest of the 2 nos. (input from user)

Following is the program to find the greatest no. :-





#include <stdio.h>

int main()

{

int a,b,c;

printf("Program to determine the greatest number among the given two numbers\n");

printf("Please enter the first number\n");

scanf("%d", &a);

printf("Please enter the second number\n");

scanf("%d", &b);

if ((a-b)<=0)

{

printf("%d is greater than %d",b,a);

}

else

{

printf("%d is greater than %d",a,b);

}

return 0;

}
Output:-






Note- using the same logic we can design this program in C++ too

1 comment: