• +91 9723535972
  • info@interviewmaterial.com

CPlusPlus Interview Questions and Answers

Question - void main() { char *cptr = 0?2000; long *lptr = 0?2000; cptr++; lptr++; printf(” %x %x”, cptr, lptr); } Will it execute or not?

Answer - 3. For Q2: As above, won’t compile because main must return int. Also, 0×2000 cannot be implicitly converted to a pointer (I assume you meant 0×2000 and not 0?2000.) 2. Not Excute. Compile with VC7 results following errors: error C2440: ‘initializing’ : cannot convert from ‘int’ to ‘char *’ error C2440: ‘initializing’ : cannot convert from ‘int’ to ‘long *’ Not Excute if it is C++, but Excute in C. The printout: 2001 2004 3. In C++ [$]> g++ point.c point.c: In function `int main()’: point.c:4: error: invalid conversion from `int’ to `char*’ point.c:5: error: invalid conversion from `int’ to `long int*’ in C ———————————– [$] etc > gcc point.c point.c: In function `main’: point.c:4: warning: initialization makes pointer from integer without a cast point.c:5: warning: initialization makes pointer from integer without a cast [$] etc > ./a.exe 2001 2004

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners