Program to find the absolute value of given integer using
Conditional Operators

Answers were Sorted based on User's Feedback



Program to find the absolute value of given integer using Conditional Operators..

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

Program to find the absolute value of given integer using Conditional Operators..

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

Program to find the absolute value of given integer using Conditional Operators..

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

Program to find the absolute value of given integer using Conditional Operators..

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

Program to find the absolute value of given integer using Conditional Operators..

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

Program to find the absolute value of given integer using Conditional Operators..

Answer / susanta datta

16

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More C Interview Questions

What is assignment operator?

0 Answers  


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

4 Answers  


What are the different types of control structures in programming?

0 Answers  


Write a program to print numbers from 1 to 100 without using loop in c?

0 Answers  






Write a program to add a given duration with time(24hrs format)

1 Answers   Protech,


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 ?

2 Answers   NetApp,


What is hungarian notation? Is it worthwhile?

0 Answers  


implement general tree using link list

1 Answers   Wipro,


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

0 Answers  


Once I have used freopen, how can I get the original stdout (or stdin) back?

0 Answers  


How can I split up a string into whitespace-separated fields?

0 Answers  


Categories