Difference between “vector†and “array�
The size of array can is fixed.
A vector is also like an array sequentially accessed but we can increase/decrease size of a vector in a simple way than it is done for arrays, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.
well printf(”%d”)
will give an output 0
because %d returns the integer value of the variable or the number of characters in othe cases
thus the answer is 0
remember that these are Questions, and they are expecting you to look at what they are asking. Anyone that answered this question with a number would have got it wrong. Anyone answering this question with -
~Unknown value, as the method was missing a parameter, would have got it right.
Dependant on the compile and environment, this function can cause the application to crash, or cause unexpected errors.
What is the output of printf(â€Â%dâ€Â)?
“%d” is used to read the value of given variable.
But,inthis progm,It will show some garbage values
#include
#include
main()
{
printf(”%d”);
}
1.What is the output of printf(â€Â%dâ€Â)?
Ans: This statement invokes undefined behaviour, because the C langauge standard says “If there are insufficient arguments for the format, the behavior is undefined”. In some compiler implementations, this might end up printing the values of the previously declared integer, which is stored in the stack, but this is not a standard behaviour, and should not be relied upon. This might print garbage value on some implementations, and on some others this can even crash the program.
There is a known as format string vulnerability which was often used to crash programs a few years back. A string of printf(”%s”) would attempt to read data from the stack (on implementations where a stack is supported) till it attempts to read from an area which it is not supposed to access and hence would ultimately crash the program.
When shall I use Multiple Inheritance?
When we need to inherit/acquire properties from two or more superclasses in one subclass, then we can use Multiple Inheritance.
Explain working of printf.
printf is the in-built function stored in library of C. It is used to print the text written in printf() function in the output.
What are the different types of Storage classes?
auto :- used for local variables.
extern :- used for global variables.
static :- initial value is 0.
register :- uses different types of registers.
*********************************************
//snippet1
int main(){
printf(”%d”);
return 0;
}
//result = 1314976(garbage)
*********************************************
//snippet2
int one(){
printf(”%d”);
return 0;
}
int main(){
one();
}
// result = 16384
*********************************************
//snippet3
int one(){
printf(”%d”);
return 0;
}
int main(){
printf(”%d”);
one();
}
// result = -1
*********************************************
//snippet 4
int two(){
int x=10;
printf(”%d”);
return 0;
}
int main(){
two();
return 0;
}
// result = 10
*******************************************
I feel, the result is unpredictable as in the above
snippets, different situations different output
but same code( printf(”%d”); )
The code deals with stack, that we all know.. but wat
does the stack contain???
122 Comments on C and C++ questions for the interview
output of printf(”%d”); will be garbage value of integer type.
20. RTTI - Run time type identification. helps to know abt the types of variables or objects.
Difference between “vector†and “array�
The size of array can is fixed.
A vector is also like an array sequentially accessed but we can increase/decrease size of a vector in a simple way than it is done for arrays, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.
well printf(”%d”)
will give an output 0
because %d returns the integer value of the variable or the number of characters in othe cases
thus the answer is 0
What is the output of printf(â€Â%dâ€Â)
remember that these are Questions, and they are expecting you to look at what they are asking. Anyone that answered this question with a number would have got it wrong. Anyone answering this question with -
~Unknown value, as the method was missing a parameter, would have got it right.
Dependant on the compile and environment, this function can cause the application to crash, or cause unexpected errors.
printf(â€Â%dâ€Â)
however if they had written the question:
printf(â€Â%dâ€Â,1);
what wil be d output of this programme…?
main()
{
int i=5;
printf(â€Â%d%d%d%d%dâ€Â,i++,++i,i–,–i,i);
}
if you have good knowledge in c you can find
contact me:suresh.jayakumar@yahoo.co.in
What is the output of printf(â€Â%dâ€Â)?
“%d” is used to read the value of given variable.
But,inthis progm,It will show some garbage values
#include
#include
main()
{
printf(”%d”);
}
printf(â€Â%dâ€Â) will print the value present to the function stack.
try this:
main()
{
int a=10;
printf(”%d”);
}
it gives 10 as o/p since the stack contains 10…
3:
member functions can be defined in c++ structure but not for c structure.
4: = oper is used in assignment
but copy constr is used when we pass or return objects…
BOTTOMLINE:
printf(”%d”); = 0 always
printf(”%d”) = printf(”%01d”);
so it will start with ONE(1) ZERO(0);
printf(”%02d”); = 00
start with TWO(2) ZERO(0);
hope u get it
regards,
pulkit dave
1.What is the output of printf(â€Â%dâ€Â)?
Ans: This statement invokes undefined behaviour, because the C langauge standard says “If there are insufficient arguments for the format, the behavior is undefined”. In some compiler implementations, this might end up printing the values of the previously declared integer, which is stored in the stack, but this is not a standard behaviour, and should not be relied upon. This might print garbage value on some implementations, and on some others this can even crash the program.
There is a known as format string vulnerability which was often used to crash programs a few years back. A string of printf(”%s”) would attempt to read data from the stack (on implementations where a stack is supported) till it attempts to read from an area which it is not supposed to access and hence would ultimately crash the program.
The diffrence Between Structure in C and c++ is that …in C all the members of structure by default public and in C++ theu by default private.
Q19. Correct answer is “The [b]mutable[/b] keyword overrides any enclosing const statement. A mutable member of a const object can be modified.”
8. there are two types of polymorphism ,one is compile timeand another is run time.
21.yes we can do something in c but not c++,example is in c we can follow the structure ,it is necessary,but not in c++.because it is oops oriented
What are the different types of polymorphism?
There are number of polymorphisms, some of them are Function Overloading, Function Overriding and so on.
When shall I use Multiple Inheritance?
When we need to inherit/acquire properties from two or more superclasses in one subclass, then we can use Multiple Inheritance.
Explain working of printf.
printf is the in-built function stored in library of C. It is used to print the text written in printf() function in the output.
What are the different types of Storage classes?
auto :- used for local variables.
extern :- used for global variables.
static :- initial value is 0.
register :- uses different types of registers.
printf(”%d”) prints 0;
and
printf(”%s”) prints null;
why?
can ne one give me the reason..!!!
*********************************************
//snippet1
int main(){
printf(”%d”);
return 0;
}
//result = 1314976(garbage)
*********************************************
//snippet2
int one(){
printf(”%d”);
return 0;
}
int main(){
one();
}
// result = 16384
*********************************************
//snippet3
int one(){
printf(”%d”);
return 0;
}
int main(){
printf(”%d”);
one();
}
// result = -1
*********************************************
//snippet 4
int two(){
int x=10;
printf(”%d”);
return 0;
}
int main(){
two();
return 0;
}
// result = 10
*******************************************
I feel, the result is unpredictable as in the above
snippets, different situations different output
but same code( printf(”%d”); )
The code deals with stack, that we all know.. but wat
does the stack contain???
One Trackback
[...] http://www.techinterviews.com/?p=238#more-238 [...]