Question-Find the absolute value of a number entered through the
keyboard.
Solution-
Basic problem. you just need to know concept of absolute value.
#include<stdio.h>
int main()
{
int num;
printf("Enter any number\n");
scanf("%d",&num);
num>0?printf("Absolute value=%d",num):printf("Absolute value=%d\n", -num);
return 0;
}
No comments:
Post a Comment