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
Explain data encapsulation?
What is class in c++ with example?
Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort
We all know that a const variable needs to be initialized at the time of declaration. Then how come the program given below runs properly even when we have not initialized p?
daily Routine of father
Where must the declaration of a friend function appear?
Tell me what are static member functions?
What's the most powerful programming language?
When should you use global variables?
How the programmer of a class should decide whether to declare member function or a friend function?
What are move semantics?
How can you quickly find the number of elements stored in a static array?
What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0
List the merits and demerits of declaring a nested class in C++?
Which function cannot be overloaded c++?