CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES C DETAILS
Question :
A variable carries a value.(already assigned OR from Scanf..what ever the way). I want to know whether the variable is positive or negative.
Conditions:
-----------
1.NO looping logic should be used such as for ..while..etc.

2.should not use > or <.

3.should not use any numbers except 0.
We can use 0 and equality operator.
How to know the number is positive or negative?


Posted by: Siv on 5/17/2008

Contact Siv  Contact Siv
Category C Interview Questions
Rating (0.0) By 0 users
Added on 5/17/2008
Views 322
Rate it!
Answers:

void main()
{
printf("enter a value");
scanf("%d",&i);
j=(i%2==0)?even no:odd no
printf("%d",j);
}



 Posted by: Hemalatha    

Contact Hemalatha  Contact Hemalatha

int main()
{

int n=0;

scanf("%d",&n);
(n>>(sizeof(int)-1))? printf("Negative "):printf("Positive ");

return 0;
}



 Posted by: Sebastian Rajan    

Contact Sebastian Rajan  Contact Sebastian Rajan


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
Define structural language and procedural language?
View Answer
Q.8 When a 'C' function call is made, the order in which parameters passed to the function are pushed into the stack is
(a) left to right
(b) right to left
(c) bigger variables are moved first than the smaller variables.
(d) smaller variables are moved first than the bigger ones
(c) none of the above.
View Answer
how do i get started for any project?
View Answer
What is the output of
void main()
{
int a = (1,2,3);
printf("%d",a);
}

with reason.
View Answer
Write Addition of two numbers using Bitwise operators.
View Answer
How much memory does a static variable takes?
View Answer
What is file pointer and its working method?
View Answer
How to get string in files and print the string in the reverse order?
View Answer
How I can add two numbers in c language without using Arithmetic operators?
View Answer
What is pointers and its uses?
View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL C Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/12642/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.7