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
Does c++ have a hash table?
what is c++
Write about c++ storage classes?
What is abstraction with real time example?
What are the advantages of c++? Explain
Define friend function.
What is the hardest coding language to learn?
What is insertion sorting?
What is data types c++?
What is c++ and its uses?
Can user-defined object be declared as static data member of another class?
What is a constant? Explain with an example.
Is main a class in c++?
Why pointer is used in c++?
How to access a variable of the structure?