GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Placement Papers  >  Honey Well  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 4 of 5    Print  

x=8
x-=--x-x--;
printf("%d",x);

that time
the output of this is 6. but my things this output is 9. so please give me description
of this output(6).

  
Total Answers and Comments: 1 Last Update: February 05, 2007     Asked by: PANKAJ CHAUHAN 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 29, 2007 02:09:53   #1  
Renju Mathew Member Since: March 2007   Contribution: 2    

RE: x=8x-=--x-x--;printf("%d",x);
Hi Pankaj

The precedence order of the operators will be x-- , --x , - , =- respectively
As the first two operations are executed the expression
will be as follows;
x -= 7 - 7....(the x-- operation will be evaluated on the next line only)

Now the subtraction is done and the statement will be , x -= 0
Now -= operation will execute. ie x = x - 0 ie x = 7.

On the next line this value will be decremented by one because of x-- statement

Thus the value 6 will be printed..(7-1)


 
Is this answer useful? Yes | No

 Related Questions

I did not attempted the C paper but still I just had a look on C and java paper.  in C most of the question were programs and their out was  asked in LINUX environment.1)      
Latest Answer : for 2nd question, o/p - helloworldhelloworld. ( this is the case on linux)because, execution of  first printf statment stores in buffer. fork , forks helloworld. thats why, its print 2 times helloworld.In case if u placed ...

X=8x-=--x-x--;printf("%d",x);that time the output of this is 6. but my things this output is 9. so please give me descriptionof this output(6).
Read Answers (1) | Asked by : PANKAJ CHAUHAN


 Sponsored Links

 
Related Articles

C++ Standard Input Output Stream

C Standard Input Output Stream In this C tutorial you will learn about standard input stream and standard output stream explained along with syntax and examples C programming language uses the concept of streams to perform input and output operations using the keyboard and to display information on
 

printf() Function Return Value

What is the return value from printf() function? printf function always returns the number of characters printed. Let us understand this with an example: main() { int a=10; printf("%d",printf("%d %d %d", a,a,a)); } In this above program the inner printf i
 

What are the Format Specifiers used with printf?

There are several format specifiers available in printf. The format specifier used varies depending on the data type used for printing. The given below are some of the format specifiers used with printf in C program. For integer data type the format specifier used with printf is %d or %i For float
 

printf and sprintf

What is the difference between printf and sprintf? sprintf: Writes formatted data to a character string in memory instead of stdout Syntax of sprintf is: #include <stdio.h> int sprintf (char *string, const char *format [,item [,item]...]); Here, String refers to the pointer to a
 

Things To Consider When Making A Career Change

Making a career change is not easy. For one, necessary adjustments in terms of work knowledge and familiarization will surely have to start from scratch. This is one of the notable risks that anyone will surely have to go through considering that careers are usually delicate for people who may reach
 

Things To Watch Out For Your Student Loan

Things To Watch Out For Your Student Loan Getting into a college program is not an easy thing to do Although a college degree is your ticket to a future career and financial stability it nonetheless comes with a price tag And that price tag is not too easy to pay off especially if you don’
 

Common Things That Waste Time

Common Things That Waste Time In order for you to excel at time management it is important for you to be able to identify things which waste time If you cannot get these things under control your productivity will fall and you will fail to achieve your goals mosgoogle Things which waste time will de
 

C Programming - Managing Input and Output Operations

C Programming Managing Input and Output Operations In this tutorial you will learn about Single character input output String input and output Formatted Input For Scanf Input specifications for real number Input specifications for a character Printing One Line Conversion Strings and Specifiers Speci
 

SQL Server 2000: Creating Stored Procedure with Input and Output Parameters

This tutorial explains how to create and use Stored Procedures with Input Parameters and output parameters along with the screen shots and sample code Creating Stored Procedure with Input Parameters mosgoogle Input Parameters in Stored Procedures are placeholders for data that the user needs to send
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape