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
What is the copy-and-swap idiom?
How is modularity introduced in C++?
What is a block in c++?
What is the meaning of c++?
Is it possible for the objects to read and write themselves?
What is virtual destructor? What is its use?
What is format for defining a structure?
What are virtual constructors/destructors?
What are arrays c++?
What type of question are asked in GE code writing test based on c++ data structures and pointers?
Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---
How does com provide language transparency?
If there are two catch statements, one for base and one for derived, which should come first?
What is #include cmath?
What is ostream in c++?