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
Difference between overloaded functions and overridden functions
what Is DCS ? what i will get benefit when i did?
How can you quickly find the number of elements stored in a static array?
Which compiler does turbo c++ use?
Perform addition, multiplication, subtraction of 2-D array using Operator Overloading.
How can a called function determine the number of arguments that have been passed to it?
Explain public, protected, private in c++?
What is recursion?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
What is data structure in c++?
How can you differentiate between inheritance and implementation in c++?
Explain virtual destructor?
What is the extension of c++?
Why do we use using namespace std in c++?
Describe new operator and delete operator?