Write any small program that will compile in "C" but not in
"C++"?
Answer Posted / mms zubeir
There are some features in C that are truncated in C++. To
quote a few,
1. const int pi; // allowed in C.
const int pi = 3.14; // equivalent in C++.
2. char name[10];
for(int index = 0; index < 50; ++index)
{
scanf("%s", &name[index]); // sorry, I am weak in C.
}
This is allowed in C. That is, the array range checking
is not done in C. In C++, it will throw an out of range
error.
3. void function()
{
....
}
int main()
{
function(299);
return 0;
}
This is allowed in C but not in C++.
Is This Answer Correct ? | 4 Yes | 4 No |
Post New Answer View All Answers
How can I learn c++ easily?
Can a function take variable length arguments, if yes, how?
What is the use of structure in c++?
Explain the register storage classes in c++.
Can we use this pointer inside static member function?
Which is not a valid keyword a) public b) protected c) guarded
What is singleton class in c++?
Can a program run without main?
what is VOID?
What does h mean in maths?
What causes a runtime error c++?
Which bit wise operator is suitable for putting on a particular bit in a number?
What do you mean by persistent and non persistent objects?
Is it possible for a member function to use delete this?
When should we use container classes instead of arrays?