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  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
the code is:::::   if(condition)
                    printf("hello");
                   else
                    printf("world");
WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH
HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE
ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT
MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS,
RECURSION ARE ALLOWED........................
 Question Submitted By :: Vignesh1988i
I also faced this Question!!     Rank Answer Posted By  
 
  Re: the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................
Answer
# 1
#include<stdio.h>
main()
{
if(printf("hello")==0)
        printf("hello");
else
        printf("world");
}

Think is there any Other.....
 
Is This Answer Correct ?    8 Yes 3 No
Gg
 
  Re: the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................
Answer
# 2
#include<stdio.h>
void main()
{
	if(1)
	{
		printf("HELLO!");
		goto HERE;
	}
	else
	{
		HERE:
			printf("HAI....");
	}
}
 
Is This Answer Correct ?    4 Yes 4 No
Dinakaran Gct
 
 
 
  Re: the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................
Answer
# 3
but goto is not a good sort of programming ............. a 
well knowledgeable programmer wont use goto..... according 
to me........... plz think of any other logic??????????
 
Is This Answer Correct ?    1 Yes 1 No
Vignesh1988i
 
  Re: the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................
Answer
# 4
but yhe printf statement will print one "hello" and one 
world.......................... but i said it must enter to 
the if part as well as else part controls.............. 
before a long time baxk itself i tried this method......... 
then only i read the question of IBM properly
 
Is This Answer Correct ?    2 Yes 1 No
Vignesh1988i
 
  Re: the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................
Answer
# 5
//#include<stdio.h>
main()
{
 if(1)
  printf("hello");
  else;
  printf("world");
}
 
Is This Answer Correct ?    1 Yes 8 No
Manjunath.goudar
 
  Re: the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................
Answer
# 6
#include <stdio.h>

int main ( int argc, char* argv[] )
{
	if ( !printf("Hello") )
		printf ("Hello");
	else printf (" World");
}
 
Is This Answer Correct ?    7 Yes 1 No
Abdur Rab
 
  Re: the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................
Answer
# 7
int a=5,b=5;
 if(a==5)
 printf("hello");
 else;
 printf("world");
 
Is This Answer Correct ?    0 Yes 5 No
Vaibhav
 
  Re: the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................
Answer
# 8
#include<stdio.h>
#include<conio.h>
main()
{
static int i;
if(i==0)
{
printf("HELLO");
i=i+1;
main();
}
else
prinf("WORLD");
getch();
}
 
Is This Answer Correct ?    0 Yes 1 No
Suvam45
 
  Re: the code is::::: if(condition) printf("hello"); else printf("world"); WHAT WILL BE THE CONDITION IN IF IN SUCH A WAY THAT BOTH HELLO AND WORLD ARE PRINTED IN A SINGLE ATTEMPT?????? SINGLE ATTEMPT IN THE SENSE... IT MUST FIRST PRINT "HELLO" AND IT MUST GO TO ELSE PART AND PRINT "WORLD"..... NO LOOPS, RECURSION ARE ALLOWED........................
Answer
# 9
/* Solution 1: */

int main(int argc, char* argv[])
{	
	if( argc == 2 || main( 2, NULL ) )
	{
		printf("Hello ");	
	}
	else
	{
		printf("World\n");
	}
	return 0;
}

/* Solution 2 (Only for Unix and Linux): */

int main(int argc, char* argv[])
{	
	if( !fork() )
	{
		printf("Hello ");	
	}
	else
	{
		printf("World\n");
	}
	return 0;
}
 
Is This Answer Correct ?    1 Yes 1 No
Fazil
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
In scanf h is used for BFL2
any string of bits of length 'n' represents a unique non- negative integer between.............?  2
what will the following program do? void main() { int i; char a[]="String"; char *p="New Sring"; char *Temp; Temp=a; a=malloc(strlen(p) + 1); strcpy(a,p); //Line no:9// p = malloc(strlen(Temp) + 1); strcpy(p,Temp); printf("(%s, %s)",a,p); free(p); free(a); } //Line no 15// a) Swap contents of p & a and print:(New string, string) b) Generate compilation error in line number 8 c) Generate compilation error in line number 5 d) Generate compilation error in line number 7 e) Generate compilation error in line number 1 IBM1
What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }  2
WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS  4
What is a class?  2
How do I initialize a pointer to a function?  2
Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 1. Print only the alphabets . If in upper case print in lower case vice versa.  1
printf("%d",(printf("Hello")); What it returns? TCS23
if a person is buying coconuts of Rs10,and then sell that coconuts of Rs9,with the loss of one rupee.After that the person became a millaniore.how? Wipro5
C program to perform stack operation using singly linked list  3
1.what are local and global variables? 2.what is the scope of static variables? 3.what is the difference between static and global variables? 4.what are volatile variables? 5.what is the use of 'auto' keyword? 6.how do we make a global variable accessible across files? Explain the extern keyword? 7.what is a function prototype? 8.what does keyword 'extern' mean in a function declaration?  1
main() { int i,j,A; for(A=-1;A<=1;A++) prinf("%d\t",!!A); }  5
WAP to accept rollno,course name & marks of a student & display grade if total marks is above 200?  2
What are the different pointer models in c?  3
6. Which of the Following is not defined in string.h? A)strspn() B)strerror() C)memchr() D)strod() Accenture1
what is the difference between c and java?  1
void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..  1
Go through the following code sinippet char a[20]; a="Hello Orcale Test"; will this compile? Oracle3
why i join syntel? Syntel12
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

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