Wap to input two numbers. Print the smallest number
Answers
Answer:
#include <stdio.h>
int main(void)
{
int num1,num2;
printf("Enter two numbers:");
scanf("%d %d",&num1,&num2);
if(num1<num2)
{
printf("%d is smaller",num1);
}
else if(num2<num1)
{
printf("%d is smaller",num2);
}
else
{
printf("%d and %d are equal",num1,num2);
}
return 0;
}
Program:
#include<stdio. h>
int main() {
int a, b;
printf("enter 2 numbers"):
scanf("%d%d", &a,&b);
if(a>b)?printf("%d is smaller",b):printf("%d is smaller",a);
return 0;
}
Explanation:
i took 2 variables into a and b of type int
and i checked which one is greateat using a trick in c if()?true:false
which will print statements before colomn if the condition in if statement is false then it prints statements afyer the Colom.
-----hope this helps you get what you want mark as brainliest if you liked it, it would really help me. :)