ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  C++ General
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
Write any small program that will compile in "C" but not in
"C++"?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write any small program that will compile in "C" but not in "C++"?
Answer
# 1
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 ?    0 Yes 0 No
Sathish Kumar
 
  Re: Write any small program that will compile in "C" but not in "C++"?
Answer
# 2
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 ?    0 Yes 0 No
Aashish Kumar Nath
 
 
 
  Re: Write any small program that will compile in "C" but not in "C++"?
Answer
# 3
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 ?    1 Yes 0 No
Mms Zubeir
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
Write a program that read 2o numbers in and array and output the second largest number. Can anybody help??  2
Write any small program that will compile in "C" but not in "C++" Honeywell6
What will happen if I allocate memory using "new" and free it using "free" or allocate sing "calloc" and free it using "delete"?  2
catch(exception &e) { . . . } Referring to the sample code above, which one of the following lines of code produces a written description of the type of exception that "e" refers to? a) cout << e.type(); b) cout << e.name(); c) cout << typeid(e).name(); d) cout << e.what(); e) cout << e; Quark2
structure contains int, char, float how it behaves for big endian and little endian? BITS1
class Foo { int x; public: Foo(int I); }; If a class does not have a copy constructor explicitly defined one will be implicitly defined for it. Referring to the sample code above, which one of the following declarations is the implicitly created copy constructor? a) Foo(Foo *f); b) Foo(Foo &f); c) Foo(const Foo *f); d) Foo(const Foo &f); e) Foo(int); Quark3
int f() { int I = 12; int &r = I; r += r / 4; int *p = &r; *p += r; return I; } Referring to the sample code above, what is the return value of the function "f()"? a) 12 b) 15 c) 24 d) 17 e) 30 Quark2
is throwing exception from a constructor not a good practice ? Ericsson4
Explain about profiling?  1
How many bit combinations are there in a byte? Intel7
what is the size of this class class size { public: char data1; double d; int data2; char data3; double data4; short data5; }; please explain the padding for these double variables.  6
Which uses less memory? a) struct astruct { int x; float y; int v; }; b) union aunion { int x; float v; }; c) char array[10]; Quark3
What happens if an exception is throws from an, object's constructor and object's destructor? Wipro1
What are the total number of lines written by you in C/C++? What is the most complicated or valuable program written in C/C++? Intel1
What is the difference between "calloc" and "malloc"? ADP5
Given a simple program designed to take inputs of integers from 1-1000 and to output the factorial value of that number, how would you test this program? You do not have access to the code. Please be as specific as possible. Microsoft2
What are Virtual Functions? How to implement virtual functions in "C" ?  2
Which of the Standard C++ casts can be used to perform a ?safe? downcast: a) reinterpret_cast b) dynamic_cast c) static_cast d) const_cast Quark1
What are the types of STL containers?  1
how to find the maximum of 10 numbers ?  3
 
For more C++ General Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com