1 / 29

OBJECTIVE QUESTIONS

OBJECTIVE QUESTIONS. QUESTION:1. #include< iostream.h > #include< conio.h > main() { int x; for (x=1;x<=5;x++); cout << x; getch (); }. QUESTION 2. #include< iostream.h > #include< conio.h > int main() { int x; for (x=1;x<=5;x++) cout << x; cout <<++x;

delbertp
Download Presentation

OBJECTIVE QUESTIONS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OBJECTIVE QUESTIONS

  2. QUESTION:1 #include<iostream.h> #include<conio.h> main() { int x; for (x=1;x<=5;x++); cout<< x; getch(); }

  3. QUESTION 2 #include<iostream.h> #include<conio.h> int main() { int x; for (x=1;x<=5;x++) cout<< x; cout<<++x; cout<< x++; getch();}

  4. QUESTION :3 int fun(int a, int b) { if(a == 0) return 1; else if(b < a) return 0; else return fun(a-1, b-1) + fun(a-1, b); } main() { int x = 3, y = 4; cout<< fun(x, y); getch(); }

  5. QUESTION :4 #include<iostream.h> #include<conio.h> int main() { int *ptr1,**ptr2,***ptr3; int x; x=12; ptr1=&x; ptr2=&ptr1; ptr3=&ptr2; x=x+1; cout<<*ptr1<<**ptr2<<***ptr3; getch(); return 0; }

  6. QUESTION:5 #include<iostream.h> #include<conio.h> main() { inti=1; if(i<5) cout<<i; i++; getch(); }

  7. QUESTION 6: #include<conio.h> #include <iostream.h> enum xyz { a, b, c}; int main() { int x = a, y = b, z = c; int &p = x, &q = y, &r = z; p = z; p = ++q; q = ++p; z = ++q + p++; cout<< p << " " << q << " " << z; getch(); return 0; }

  8. QUESTION:7 #include<iostream.h> #include<conio.h> int main() { int a[]={0,1,2,3,4,5,6,7,8,9,10}; inti=0,num; num=a[++i+a[++i]]+a[++i]; cout<<num; getch(); return 0; }

  9. QUESTION:8 #include<iostream.h> #include<conio.h> union codeletter { int code; char letter; }c1; void printc1() { cout<<"\n the code is:"<<c1.code; cout<<"\n the letter is:"<<c1.letter; } int main() { c1.code=101; c1.letter='f'; printc1(); getch(); return 0; }

  10. QUESTION 9 • #include<iostream.h> • #include<conio.h> • main() • { • void func(int,int=1,int=3,int=3); • func(2,3); • getch(); • } • void func(intx,inty,intz,int l) • { • cout<<x+y+z+l; • }

  11. QUESTION :10 #include<iostream.h> #include<conio.h> main() { int n=5, f=1; while(n>0) f*=n--; cout<<f; getch(); }

  12. QUESTION :11 #include<iostream.h> #include<conio.h> void procedure(int,int,int); int main() { int x=10; procedure(x,x++,++x); getch(); return 0; } void procedure(inta,intb,int c) { cout<<a<<"\t"<<b<<"\t"<<c; }

  13. QUESTION :12 #include<iostream.h> #include<conio.h> main() { inti=1; while(i<5) cout<<i; i++; getch(); }

  14. QUESTION: 13 #include<iostream.h> #include<conio.h> main() { inti=100; for(int j=1; j<=4;j++) cout<<i<<j; getch(); }

  15. QUESTION :14 #include<iostream.h> #include<conio.h> int test(inta,int b) { b+=5; a*=++b; return a; } int main() { int x=5; x=test(x,x); cout<<x; getch(); return 0;}

  16. QUESTION :15 #include<iostream.h> #include<conio.h> using namespace std; int main () { int firstvalue = 5, secondvalue = 15; int * p1, * p2; p1 = &firstvalue; p2 = &secondvalue; *p1 = 10; *p2=*p1; p2=p1; *p1=130; cout << "firstvalue is " << firstvalue<<endl; cout << "secondvalue is " << secondvalue << endl; cout<<*p1<<endl<<*p2; getch(); return 0; }

  17. QUESTION 16 #include <iostream> #include<conio.h> using namespace std; int main () { int x=5,y; y=x++ + ++x +--x - x++; cout<<x<<y; getch(); return 0; }

  18. QUESTION 17 #include<iostream.h> #include<conio.h> main() { inti=1; for(;i<5;i++); cout<<i++; getch(); }

  19. QUESTION 18 #include<iostream.h> #include<conio.h> void print(int x); int main() { print(5); getch(); } void print(int x) { if(x>0) print(--x); cout<<x; }

  20. QUESTION :19 #include<iostream.h> #include<conio.h> int main() { int a[4]={23,45,67,89,76}; int i; for(i=0;i<=4;i++) cout<<a[i]; getch(); }

  21. QUESTION :20 #include<iostream.h> #include<conio.h> class x { private: int a,y; public: x() { a=12; y=2; } void show(x c) { cout<<c.a+c.y }}; int main() {x ob; ob.show(ob); getch(); }

  22. QUESTION :21 #include<iostream.h> #include<conio.h> int main() { int a[5]={1,2,3,4,5}; cout<<*a++; getch(); }

  23. QUESTION:22 #include<iostream.h> #include<conio.h> int main() { char a[]="hello"; char *p; p=a; cout<<*(++p); getch(); }

  24. QUESTION :25 #include<iostream.h> #include<conio.h> class abc { public: float a;int x; abc() { cout<<"hello";} ~abc() {cout<<"destructor called"; } }; int main() { abc ob; cout<<sizeof(ob); getch();}

  25. QUESTION:26 #include<iostream.h> #include<conio.h> class abc { public: int x,y; private: abc() { x=0; y=9; cout<<x<<y; } };int main() { abc ob; getch(); }

  26. QUESTION :27 #include<iostream.h> #include<conio.h> int main() { int a[10],i,*p; for(i=0;i<=9;i++) cin>>a[i]; p=&a[0]; for(i=0;i<=9;i++) cout<<*(p+i+1); getch(); }

  27. QUESTION :28 #include <iostream.h> #include<conio.h> void Values(int n1, int n2 = 10) { cout << "1st value: " << n1; cout << "2nd value: " << n2; } int main() { Values(1); Values(3, 4); getch(); return 0; }

  28. QUESTION :29 #include <iostream.h> #include<conio.h> int array1[] = {1200, 200, 2300, 1230, 1543}; int array2[] = {12, 14, 16, 18, 20}; int temp, result = 0; int main() { for (temp = 0; temp < 5; temp++) { result += array1[temp]; } for (temp = 0; temp < 4; temp++) { result += array2[temp]; } cout << result; getch(); return 0; }

  29. QUESTION 30 #include <iostream.h> #include<conio.h> void func(int a, bool flag = true) { if (flag == true ) { cout << "Flag is true. a = " << a;}{ cout << "Flag is false. a = " << a; } } int main() { func(2); cout<<"\n"; func(200, false); getch(); return 0; }

More Related