ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  C Code
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
1)
int i=5;
j=i++ + i++ + i++;
printf("%d",j);This code gives the answer 15.But if we 
replace the value of the j then anser is different?why?

2)int i=5;
printf("%d",i++ + i++ + i++);
this givs 18.
 Question Submitted By :: Kaduchandrakant
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.
Answer
# 1
in the 1st case post increment will be done at the end of
the statement that is 15 is assigned to 'j' then 'i' will
increment 3 times bcoz 3 post increments r there.
    in the later case first 15 assign to 'i' then increment
3 times and assign to 'i'
 
Is This Answer Correct ?    2 Yes 1 No
Divakar
 
  Re: 1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.
Answer
# 2
Remember increment operator is compiler depended.
1.
     if u compiled in TC++ then u will get j=18
     if u compile in VC++ then u will get j=15.   
2.   
     if u compiled in TC++ then u will get j=18
     if u compile in VC++ then u will get j=15.
 
Is This Answer Correct ?    0 Yes 1 No
Satyasaran
 
 
 
  Re: 1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.
Answer
# 3
I have tried the second case in linux with gcc. But, the
output is 15 and not 18.
 
Is This Answer Correct ?    1 Yes 0 No
Gireesh
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
Find the largest number in a binary tree Infosys4
Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all. Microsoft2
Finding a number which was log of base 2 NetApp1
how to return a multiple value from a function? Wipro1
How to read a directory in a C program?  3
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it. Microsoft4
How we will connect multiple client ? (without using fork,thread) TelDNA2
Program to find the largest sum of contiguous integers in the array. O(n)  5
print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!! Tata-Elxsi14
What is "far" and "near" pointers in "c"...?  2
Print an integer using only putchar. Try doing it without using extra storage.  1
1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18. Infosys3
write a program to Insert in a sorted list Microsoft4
Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9). Microsoft8
How to return multiple values from a function?  4
How do you write a program which produces its own source code as its output?  4
Finding a number multiplication of 8 with out using arithmetic operator NetApp7
How to reverse a String without using C functions ? Wipro8
You are given any character string. Find the number of sets of vowels that come in the order of aeiou in the given string. For eg., let the given string be DIPLOMATIC. The answer returned must be "The number of sets is 2" and "The sets are "IO and AI". Vowels that form a singleton set must be neglected. Try to post the program executable in gcc or g++ or in java.  2
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. Microsoft8
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com