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........................
Answers were Sorted based on User's Feedback
Answer / gg
#include<stdio.h>
main()
{
if(printf("hello")==0)
printf("hello");
else
printf("world");
}
Think is there any Other.....
| Is This Answer Correct ? | 62 Yes | 10 No |
Answer / abdur rab
#include <stdio.h>
int main ( int argc, char* argv[] )
{
if ( !printf("Hello") )
printf ("Hello");
else printf (" World");
}
| Is This Answer Correct ? | 17 Yes | 6 No |
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 ? | 5 Yes | 5 No |
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 ? | 4 Yes | 4 No |
Answer / anudyuti
#include <stdio.h>
int executeboth();
void main()
{
both();
}
int both()
{
static int i=0;
if(i++==0 ? executeboth():1)
{
printf ("Hello");
}
else
{
printf (" World");
}
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / srikanth
int main()
{
if(fork())
{
printf("hello");
}
else
{
printf("world");
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
#include<stdio.h>
void main()
{
if(1)
{
printf("HELLO!");
goto HERE;
}
else
{
HERE:
printf("HAI....");
}
}
| Is This Answer Correct ? | 18 Yes | 19 No |
Answer / subbu
#include<stdio.h>
int main()
{
if(!printf("Hello")
{
printf("Hello");
}
else
printf("World");
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / fazil
/* 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 ? | 4 Yes | 7 No |
differnce between do and do while
What are pointers? What are different types of pointers?
What is the scope of local variable in c?
What are the main characteristics of c language describe the structure of ac program?
What are the types of data structures in c?
Explain what are multibyte characters?
What is the size of enum in bytes?
How can type-insensitive macros be created?
Is file a keyword in c?
Just came across this question, felt worth sharing, so here it is I want you to make a C/C++ program that for any positive integer n will print all the positive integers from 1 up to it and then back again! Let's say n=5 I want the program to print: 1 2 3 4 5 4 3 2 1. Too easy you say? Okay then... You can ONLY USE: 1 for loop 1 printf/cout statement 2 integers( i and n) and as many operations you want. NO if statements, NO ternary operators, NO tables, NO pointers, NO functions!
in a town the percentage of men is 52 the percentage of total literacy is 48 if total percentage of literate men is 35 of the total population write a program to find the total no of the literate men and women if the population of the town is 80000
What is struct node in c?