Give the output of the program:
void thing1();
void thing2();
int main()
{
printf("3 ");
thing1();
printf("4");
thing(2);
printf("5");
return 0;
}
void thing1()
{
printf("Gotcha!" );
}
void thing2()
{
printf("HA! ");
}
Answer : Error (Linker error)
Explanation: See The
program might have run even if we didn't add the header file
#include<stdio.h> to use built-in function
like printf and scanf.
-But it will generate Warning regarding it.
- So the program will run fine but thing(2) this
function is not defined it should be either thing2() so that it
would have run fine.
- So in the end the program has generated a error with undefined
reference to `thing' error.
#Code
// Header is not included but the program will run with
warnings.
//#include<stdio.h>
// Function declaration
void thing1();
void thing2();
int main()
{
printf("3 ");
// Calling function thing1()
thing1();
printf("4");
// Calling function tinng2 which is not defined.
// Or it should be thing2()
thing(2);
//thing2(2);
printf("5");
return 0;
}
// Function defination
void thing1()
{
printf("Gotcha!");
}
void thing2()
{
printf("HA! ");
}
#Output
#Running Code
// Header is not included but the program will run with
warnings.
//#include<stdio.h>
// Function declaration
void thing1();
void thing2();
int main()
{
printf("3 ");
// Calling function thing1()
thing1();
printf("4");
// Calling function tinng2 which is not defined.
// Or it should be thing2()
//thing(2);
thing2();
printf("5");
return 0;
}
// Function defination
void thing1()
{
printf("Gotcha!");
}
void thing2()
{
printf("HA! ");
}
#Running Output
#Note If need any help then ping me in the comments I will be glad to help you out ^_^ and If you liked the answer and explanation then please give a thumbs up I really need a +ve feedback at the moment.
Get Answers For Free
Most questions answered within 1 hours.