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


Please Help Members By Posting Answers For Below Questions

How can I learn c++ easily?

836


Can a function take variable length arguments, if yes, how?

769


What is the use of structure in c++?

755


Explain the register storage classes in c++.

894


Can we use this pointer inside static member function?

836


Which is not a valid keyword a) public b) protected c) guarded

1001


What is singleton class in c++?

794


Can a program run without main?

889


what is VOID?

826


What does h mean in maths?

841


What causes a runtime error c++?

821


Which bit wise operator is suitable for putting on a particular bit in a number?

948


What do you mean by persistent and non persistent objects?

1061


Is it possible for a member function to use delete this?

806


When should we use container classes instead of arrays?

799