8. WAP to find the absolute value of a number entered through the keyboard without absolute function using Conditional Operator.

Posted: September 23, 2012 in CSE Sem1, ECE Sem1, Lab 10, Lab 10, Lab 11A, Lab 11A, MECH Sem1
#include<stdio.h>   
int main()  
{  
  int a,b;  
  printf("enter the value of a");  
  scanf("%d",&a);  
  if(a<0)  
  {  
   b=a*-1;  
   printf("\nabsolute value of %d is %d",a,b);  
  }  
  else  
   {  
     printf("\nabsolute value=%d",a);  
   }  
   return 0;  
}  
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s