Wednesday, April 9, 2008

C++ Solved questions 2008 - 13

Cplusplus C++ Technical Questions and programs with solutions / answers

1. Why main function is so special. Give two reasons?
Ans. Whenever a C++ program is executed only the main() is executed i.e., execution of the program starts and ends at main(). The main() is the driver function of the program. If it is not present in a program, no execution can take place.

2.Name the header file of C++ to which following functions belong:
(i) strcat() (ii) scanf() (iii) getchar() (iv) clrscr( )
Ans. (i) string.h (ii) stdio.h (iii) stdio.h (iv) conio.h

3.Find the syntax error(s), if any, in the following program:
#include
main()
{
int x[5],*y,z[5];
for(i=0;i<5;i++) y="z;" x="y;">4. Give the output of the following program.
#include
void main( )
{
char *p="Difficult";
char c;
c=*p++;
printf("%c",c);
}
Ans. D

5. Write the output of the following program.
#include
static int i=100;
void abc( )
{
static int i=8;
cout<<"first="<6.Write a C++ function that converts a 2-digit octal number into binary number and prints the binary equivalent.
Ans.
#include
#include
void binary(int a)
{
int i,b[5];
for(i=3;i>=1;i--)
{
b[i]=a%2;
a=a/2;
}
for(i=1;i<=3;i++) cout<>n;
x=n/10;
y=n%10;
binary(x);
binary(y);
getch();
}

Download free online previous years and latest IT companies latest / recent technical placement papers and interview questions with solutions / solved with answers for 2007 and 2008. Complete programs for expert, basic, beginner, advanced, general technical interview questions and Exams papersfor Top Software Developers Companies, Experts Jobs for application developers for various computer languages like C, C++, Java, Javascript, Web Designers, Animation companies, Animators, Graphic Designers, Coders, ASP .net, Net, Basic PC and internet / windows questions, etc. for various MNC, MNCs like Infosys, wipro, tcs, satyam computers, hcl, microsoft, cisco, cognizant, web designing agencies, studios, mastek, tech mahindra, accenture, IBM etc important, mostly asked questions for freshers, walkin interviews and fully detailed placement question papers.


No comments: