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
Write about c++ storage classes?
What is the difference between global variables and local variable
How can you say that a template is better than a base class?
What is the difference between while and do while loop? Explain with examples.
What is flush c++?
What are structs in c++?
what is C++ objects?
What is the array and initializing arrays in c++?
What is virtual base class uses?
Where is atoi defined?
What do you mean by inheritance in c++?
What is the main function c++?
Can we make copy constructor private in c++?
What is size_type?
In c++, what is the difference between method overloading and method overriding?