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
Can constructor be static in c++?
Describe the syntax of single inheritance in C++?
What is expression parser in c++
What is null pointer and void pointer?
What are put and get pointers?
Which is not a valid keyword a) public b) protected c) guarded
Differentiate between late binding and early binding. What are the advantages of early binding?
Differentiate between the manipulator and setf( ) function?
What parameter does the constructor to an ofstream object take?
What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0
Does c++ cost money?
Which format specifier is used for printing a pointer value?
How do you write a function that can reverse a linked-list?
What are maps in c++?
Explain how to initialize a const member data.