Write any small program that will compile in "C" but not in
"C++"?
Answers were Sorted based on User's Feedback
Answer / sathish kumar
Hi All,
U can write many programs which will compile in C and not
in C++. Sample program.
const i; /* this is possible in C but not in C++ */
const int i; // it should be done like this in C++.
Thanks & Regards
Sathish Kumar
Is This Answer Correct ? | 10 Yes | 2 No |
Answer / nousilal badavath
int new;//allowed in c but not in c++ because in c++
Is This Answer Correct ? | 7 Yes | 1 No |
Answer / aashish kumar nath
We can do many programs which will run in C but not in C++
like if we declare
int class=8 /*It will run in C but not in c++ */
Is This Answer Correct ? | 6 Yes | 1 No |
Answer / 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 |
How do you establish a has-a relationship?
What is the precedence when there is a global variable and a local variable in the program with the same name?
How is static data member similar to a global variable?
Write a program to find the Factorial of a number
What are the 2 main types of data structures?
What are smart pointer? Whats its use?
How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?
Explain stack unwinding.
What is the difference between equal to (==) and assignment operator (=)?
What is the difference between set and map in c++?
What is wrapper class in c++?
How do you differentiate between overloading the prefix and postfix increments?