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 ? | 37 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 is assignment operator?
write c program to display output 10(10+20)+(10+20+30)+ ... n term
0 Answers Hindustan Gum Chemicals,
write a program to arrange the contents of a 1D array in ascending order
What are the different types of control structures in programming?
Write a program to print numbers from 1 to 100 without using loop in c?
Write a program to add a given duration with time(24hrs format)
if function is declared as static in one source file, if I would like to use the same function in some other source file...is it possible....how ?
What is hungarian notation? Is it worthwhile?
implement general tree using link list
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
Once I have used freopen, how can I get the original stdout (or stdin) back?
How can I split up a string into whitespace-separated fields?