Program to find the absolute value of given integer using
Conditional Operators
Answers were Sorted based on User's Feedback
Answer / ravi vishwakarma
#include<stdio.h>
#include<conio.h>
void main()
{
int m;
printf("enter the value of m:");
scanf("%d",&m);
(m>=0?printf("%d",m):printf("%d",-(m)));
getch();
}
Is This Answer Correct ? | 38 Yes | 6 No |
Answer / apoorv gaurav
#include<stdio.h>
int main()
{
int a;
printf("Enter any number");
scanf("%d",&a);
if(a>=0)
printf("%d",a);
printf("%d",(-1*a));
return 0;
}
Is This Answer Correct ? | 7 Yes | 5 No |
Answer / vignesh1988i
#include<stdio.h>
#include<conio.h>
void main()
{
int m;
printf("enter the value of m:");
scanf("%d",&m);
(m>=0?printf("%d",m):printf("%d",-(-m)));
getch();
}
Is This Answer Correct ? | 37 Yes | 38 No |
Answer / abdur rab
#include <stdio.h>
int main ( int argc, char* argv [] )
{
int value = -10;
printf ("\n%d", ( value >= 0 ) ? value : ~(value)
+1 );
}
Is This Answer Correct ? | 16 Yes | 18 No |
Answer / bushahiro emmy
#include<stdio.h>
#include<math.h>
int main()
{
int X;
printf("Entrez un nombre: ");
scanf("%d",&X);
printf("la valeur absolue de %d est %.2lf.\n",X,fabs
(X));
return 0;
}
Is This Answer Correct ? | 7 Yes | 9 No |
What are the difference between a free-standing and a hosted environment?
WHOT IS CHAR?
what is the disadvantage of using macros?
what is the diffrenet bettwen HTTP and internet protocol
what will be the output of "printf("%d%d",scanf("%d% d",&a,&b))".provide an explation regarding the question
What is f'n in math?
input may any number except 1,output will always 1.. conditions only one variable should be declare,don't use operators,expressions,array,structure
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
what is the difference between getch() and getchar()?
c program to input values in a table(using 2D array) and print odd numbers from them
How do I use void main?
What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }