Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Explain data encapsulation?

1131


What is class in c++ with example?

1277


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

1049


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?

1081


daily Routine of father

1412


Where must the declaration of a friend function appear?

961


Tell me what are static member functions?

1086


What's the most powerful programming language?

1039


When should you use global variables?

1215


How the programmer of a class should decide whether to declare member function or a friend function?

1121


What are move semantics?

1162


How can you quickly find the number of elements stored in a static array?

1098


What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0

961


List the merits and demerits of declaring a nested class in C++?

1032


Which function cannot be overloaded c++?

1116