Prepare
Practice
Interview
Aptitude
Reasoning
English
GD
Placement papers
HR
Current affairs
Engineering
MCA
MBA
Online test
Login
Online Practice Test
>
C
« Previous
Next »
What is the output of the following code?
# define i 20
main()
{
printf("%d..",i);
fun();
printf("%d",i);
}
void fun()
{
#undef i
#define i 30
}
Options
- 20..30
- 20..20
- 0
- Error
CORRECT ANSWER : 20..20
Discussion Board
Answer- 20..20
It will compile, with warning 'implicit declaration of function 'fun'. To avoid this warning must define the prototype of function before main function or write function 'fun' before the main function.
But in this program, if we write 'fun' function before the main then output is 30..30 and if function writes after main then output is 20..20.
Sapna 02-17-2017 12:09 AM
Answer is ERROR..!!
[Error]'fun()' was not declare in this scope.
Tahir 05-29-2016 01:57 AM
good answer
it will compile, correct answer 20..20.. , if you put the fun function before the main it will be 30..30..
paul 10-8-2014 05:41 AM
Ans is ERROR.
Because if we define the function after main() we should declare that function before the main.
SAI KUMAR 09-12-2014 05:38 AM
to test my c knowledge
this test is very useful to test my skill.THANK YOU
keerthana.B 07-9-2014 07:48 AM
wrong answer
It will not compile. It is using fun() before it was declared.
laca 05-11-2014 10:53 AM
correct answer
undef scope is only inside fun()
ajinkya 04-24-2014 09:07 AM
« Previous
Next »
Write your comments
*
*
Email must be in the form someone@domain.com
*
*
Enter the code shown above:
Please enter the code shown above
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)
Related Content
C test (42)
C (12)
C++ for beginners (10)
C++ (20)
C++ (24)
C++ (18)
C++ (14)
C++ (12)
C++ (15)
C++ (15)
Data structure (20)
Data structure (10)
Data structure (10)
Data structure (10)
PERL (25)
VC++ (11)
Oops (30)
Mainframe (41)
Mainframe (15)
Embedded systems (15)
OOAD (49)
Advertisement
▲