1.d) Find The Output of The Following Program
1.d) Find The Output of The Following Program
h> void main( ) { int Array[]={4,6,10,12}; int *pointer=Array; for(int I=1;I<=3;I++) { cout<<*pointer<<#; pointer++; } cout<<endl; for(I=1;I<=4;I++) { (*pointer)*=3; --pointer; } for(I=1;I<5;I++) cout<<Array[I-1]<<@; cout<<endl; }
2007 Outside Delhi: 1.d) Find the output of the following program: #include<iostream.h> void main( ) { int Numbers[]={2,4,8,10}; int *ptr=Numbers; for(int C=1;C<3;C++) { cout<<*ptr<<@; ptr++; } cout<<endl; for(C=0;C<4;C++) { (*ptr)*=2; --ptr; } for(C=0;C<4;C++) cout<<Numbers[C]<<#; cout<<endl; } 1.d) Find the output of the following program: #include<iostream.h> #include<string.h> class state { char *state_name; int size;
public: state( ) { size=0; state_name=new char[size+1]; } state(char *s) { size=strlen(s); state_name=new char[size+1]; strcpy(state_name,s); } void display( ) { cout<<state_name<<endl; } void Replace(state &a, state &b) { size=a.size+b.size; delete state_name; state_name=new char[size+1]; strcpy(state_name,a.state_name); strcat(state_name,b.state_name); } }; void main( ) { char *temp=Delhi; state state1(temp),state2(Mumbai),state3(Nagpur),S1,S2; S1.Replace(state1,state2); S2.Replace(S1,state3); S1.display( ); S2.display( );} 3
2006 Outside Delhi: 1.d) Find the output of the following program: #include<iostream.h>#include<string.h> class student { char *name; int I; public: student( ) { I=0; name=new char[I+1]; }
student(char *s) { I=strlen(s); name=new char[I+1]; strcpy(name,s); } void display( ) { cout<<name<<endl; } void manipulate(student &a, student &b) { I=a.I+b.I; delete name; name=new char[I+1]; strcpy(name,a.name); strcat(name,b.name); } }; void main( ) { char *temp=Jack; Student name1(temp),name2(Jill),name3 (John) ,S1,S2; S1.manipulate(name1,name2); S2.manipulate(S1,name3); S1.display( );S2.display( ); } 3
Question Excerpt From C++ OUTPUTS FOR CBSE STD-XII Find the output :void main() { int k[ ] = {100,200,300,400,500,600,700}; int *t=k+2; cout<<*t; cout<<"\n"<<*(t+2) + *t; Q.1) *t = *t + 10; cout<<*t; t=t+3; cout<<*t *t = *t + *(t-2); cout<<*t; } 300 A. 900
B.
320 600 1000 300 800 310 600 1000 100 900 310 600 1000 300 800 310 600 900
C.
D.
None of the above Find the output:int p[ ] = {50,60,70,80,90,100}; int *q[ ]; for(int i =0;i<6;i++) { q[i] = &p[i]; } for(int i=5;i>=1;i--) { Q.2) q[i] = q[i-1]; *q[i] = *q[i] + *p * 2; } for(int i=0;i<6;i++) { cout<<"\n "<<p[i]; <p[i]; } E. </p[i]; 160 160 170 180 190
A.
100 150 150 150 150 150 150 150 160 170 180 190 190 150 160 170 180 190 200 150 160 170 180 190 100
B.
C.
D.
E.
#include #include #include void main() { clrscr(); char *S="OnLine Test1iN2g"; char *t=S; Q.3) cout<<*(t+5)<<"\n"; t=t+2; *t=*t+1; cout.write(t,5);cout<<"\n"; cout<<s<<"\n"; char *k=S; while(*k!=NULL) {
if(isupper(*k)) { *k=*(k+1); } else if(isdigit(*(k+1))) { *k=toupper(*k); } else if(!isalpha(*k) && !isdigit(*k)) { *k='/'; } k++; } cout<<"\n"<S; <s; getch(); } </s; </s<<"\n"; e Mine OnMine Test1iN2g nniine/eesT1i22g n Line OnMine Test1iN2g B. nniine/eesT1i22g
A.
D.
E.
void main()
Q.4)
{ KEY aKEY; strcpy(aKEY.word, #define); aKEY.count=0; changekeyword(aKEY); cout<<"\n"<<aKEY.word<<"\t"<<aKEY.count;<akey.word<< \t<<akey.count<<="" \n;</akey.word<<> getch(); } void changekeyword(KEY somekey) { strcpy(somekey.word, const); somekey.count=1; <somekey.word<< style="mso-tab-count: 2" \t="" <<somekey.count<<="" \n; </somekey.word<<>}
A.
const 0 define 1 define 0 const 1 const 1 define 0 const 10 define 0 const 1 define 10
B.
C.
D.
E.
Find the output of the following program : #include #include Q.5) class state { char *state_name; int size; public:
state( ); { size=0; state_name=new char[size+1]; } state(char *s) { size = strlen(s) ; state_name = new char[size+1]; strcpy(state_name,s); } void display( ) {cout<<state_name<<endl;}< b=""></state_name<<endl;}<> void Replace (state & a, state & b) { size = a.size + b.size; delete state_name; state_name = new char[size+l]; strcpy(state_name, a.state_name); strcat(state_name, b.state_name); } }; void main( ) { char * temp = Delhi; state state1 (temp), state2(Mumbai), state3(Nagpur), S1, S2; S1.Replace(state1, state2); S2. Replace(S1, state3); S1.display( ); S2.display( ); } A. B. C. D. DelhiMumbai DelhiMumbaiNagpur Delhi Mumbai Delhi Mumbai Nagpur DelhiMumbaiNagpur DelhiMumbai
MumbaiDelhi DelhiMumbaiNagpur DelhiMumbai E. NagpurDelhiMumbai Find the output of the following program : #include void main( ) { long NUM= 1234543; int F=0, S=0; do Q.6) { int Rem = NUM% 10 ; if (Rem % 2 !=0) F+=Rem; else S+=Rem; NUM /=10;
A. B. C. D. E.