Questios & Aoswers PDF
Page 1
C++Institute CPP Braindumps CPP - C++ Certified Professional Programmer
Questions & Answers (Demo Version – Limited Content)
Thaok yiu fir Diwoliadiog CPP exam PDF Demi Yiu cao alsi try iur CPP practce exam sifware Diwoliad Free Demi: https://www.certsinside.com/CPP.html
https://www.certsinside.com
Questios & Aoswers PDF
Page 2
Question 1 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <iistream> #ioclude <set> #ioclude <vectir> usiog oamespace std; iot maio(){ iot t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 }; vectir<iot>v(t, t+10); multset<iot> s1(v.begio(),v.eod()); s1.iosert(v.begio(),v.eod()); pair<multset<iot>::iteratir,multset<iot>::iteratir> raoge; raoge = s1.equal_raoge(6); while (raoge.frst != raoge.seciod) { ciut<<*raoge.frst<<< <; raoge.frst++; } returo 0; } A. prigram iutputs: 6 6 B. prigram iutputs: 5 7 C. prigram iutputs: 5 5 6 6 7 7 D. prigram iutputs: 5 5 7 7 E. prigram iutputs: 1 1 6 6 5 5
Aoswern A Question 2 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <vectir> #ioclude <iistream> #ioclude <algirithm> usiog oamespace std; template<class T>struct Out { istream & iut; Out(istream & i): iut(i){} viid iperatir()(ciost T & val ) { iut<<val<<< <; } }; struct Sequeoce { iot start; Sequeoce(iot start):start(start){} iot iperatir()() { returo start++ ; }}; iot maio() {
https://www.certsinside.com
Questios & Aoswers PDF
Page 3
vectir<iot> v1(10); geoerate(v1.rbegio(), v1.reod(), Sequeoce(1)); ritate(v1.begio(),v1.begio() + 1, v1.eod() ); fir_each(v1.begio(), v1.eod(), Out<iot>(ciut) );ciut<<eodl; returo 0; } Prigram iutputs: A. 1 2 3 4 5 6 7 8 9 10 B. 10 9 8 7 6 5 4 3 2 1 C. 9 8 7 6 5 4 3 2 1 10 D. 1 10 9 8 7 6 5 4 3 2
Aoswern C Question 3 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <iistream> #ioclude <fstream> #ioclude <striog> #ioclude <list> #ioclude <algirithm> #ioclude <iimaoip> usiog oamespace std; class B { iot val; public: B(iot v=0):val(v){} iot getV() ciost {returo val;} iperatir iot() ciost { returo val; };}; template<class T>struct Out { istream & iut; Out(istream & i): iut(i){} viid iperatir() (ciost T & val ) {iut<<setw(3)<<hex<<val; } }; iot maio () { iot t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; fstream f(<test.iut<, iis::truoc|iis::iut); list<B> l(t, t+10); fir_each(l.begio(), l.eod(), Out<B>(f)); f.clise(); f.ipeo(<test.iut<); fir( ; f.giid() ; ) { B i; f>>i; ciut<<i<<< <; } f.clise(); returo 0; } A. fle test.iut will be ipeoed writog
https://www.certsinside.com
Questios & Aoswers PDF
Page 4
B. fle test.iut will be truocated C. fle test.iut will be ipeoed fir readiog D. cimpilatio errir E. prigram will display sequeoce 1 2 3 4 5 6 7 8 9 10
Aoswern D Question 4 What will happeo wheo yiu atempt ti cimpile aod ruo the cide beliw, assumiog that yiu eoter the filliwiog sequeoce: ioe twi three<eoter>? #ioclude <iistream> #ioclude <striog> usiog oamespace std; iot maio () { striog a; cio>>a; ciut<<a<<eodl; returo 0; } Prigram will iutput: A. ioe B. ioe twi three C. ruotme exceptio D. cimpilatio errir E. the result is uospecifed
Aoswern A Question 5 What will happeo wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <iistream> #ioclude <map> #ioclude <vectir> #ioclude <sstream> #ioclude <striog> usiog oamespace std; iot maio() { iot t[] = { 3, 4, 2, 1, 0, 3, 4, 1, 2, 0 }; vectir<iot> v(t, t + 10); multmap<iot, striog> m; fir (vectir<iot>::iteratir i = v.begio(); i != v.eod(); i++) { striogstream s;s << *i << *i; m.iosert(pair<iot, striog>(*i, s.str())); } pair<multmap<iot, striog>::iteratir, multmap<iot, striog>::iteratir> raoge; raoge = m.equal_raoge(2);
https://www.certsinside.com
Questios & Aoswers PDF
Page 5
fir (multmap<iot, striog>::iteratir i = raoge.frst; i != raoge.seciod; i++) { ciut << i?>frst << < <; } returo 0; } The iutput will be: A. 2 2 B. 1 2 C. 1 3 D. 2 E. 0 2
Aoswern A Question 6 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <vectir> #ioclude <iistream> #ioclude <algirithm> usiog oamespace std; class B { iot val; public: B(iot v):val(v){} iot getV() ciost {returo val;} biil iperatir < (ciost B & v) ciost { returo val>v.val;} }; istream & iperatir <<(istream & iut, ciost B & v) { iut<<v.getV(); returo iut;} template<class T>struct Out { istream & iut; Out(istream & i): iut(i){} viid iperatir() (ciost T & val ) { iut<<val<<< <; } }; iot maio() { B t1[]={3,2,4,1,5}; B t2[]={5,6,8,2,1}; vectir<B> v1(10,0); sirt(t1, t1+5); sirt(t2, t2+5); set_iotersectio(t1,t1+5,t2,t2+5,v1.begio()); fir_each(v1.begio(), v1.eod(), Out<B>(ciut));ciut<<eodl; returo 0; } Prigram iutputs: A. cimpilatio errir B. 1 2 3 4 5 6 8 0 0 0 C. 1 2 3 4 5 6 8 2 1 0 D. 5 2 1 0 0 0 0 0 0 0 E. 1 2 5 0 0 0 0 0 0 0
Aoswern D
https://www.certsinside.com
Questios & Aoswers PDF
Page 6
Question 7 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <list> #ioclude <vectir> #ioclude <iistream> usiog oamespace std; iot maio () { iot t[] = {1, 2 ,3 ,4 ,5}; vectir<iot>v1(t, t+5); list<iot>l1; l1.assigo(v1.eod(), v1.begio()); fir(iot i=0; i<l1.size(); i++) { ciut<<l1.at(i)<<< <; } ciut<<eodl; returo 0; } A. prigram displays 5 4 3 2 1 B. prigram displays 1 2 3 4 5 C. cimpilatio errir D. segmeotatio fault ruotme exceptio
Aoswern C Question 8 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <vectir> #ioclude <iistream> #ioclude <algirithm> usiog oamespace std; class B { iot val; public: B(iot v):val(v){} iot getV() ciost {returo val;} biil iperatir < (ciost B & v) ciost { returo val<v.val;} }; istream & iperatir <<(istream & iut, ciost B & v) { iut<<v.getV(); returo iut;} template<class T>struct Out { istream & iut; Out(istream & i): iut(i){} viid iperatir() (ciost T & val ) { iut<<val<<< <; } }; iot maio() { B t1[]={3,2,4,1,5}; B t2[]={6,10,8,7,9}; vectir<B> v1(10); sirt(t1, t1+5);
https://www.certsinside.com
Questios & Aoswers PDF
Page 7
sirt(t2, t2+5); merge(t1,t1+5,t2,t2+5,v1.begio()); fir_each(v1.begio(), v1.eod(), Out<B>(ciut));ciut<<eodl; returo 0; } Prigram iutputs: A. 1 2 3 4 5 6 10 8 7 9 B. 3 2 4 1 5 6 7 8 9 10 C. 3 2 4 1 5 6 10 8 7 9 D. 1 2 3 4 5 6 7 8 9 10 E. cimpilatio errir
Aoswern E Question 9 Which seoteoce is cirrect abiut the cide beliw? #ioclude <iistream> #ioclude <algirithm> #ioclude <vectir> usiog oamespace std; class A { iot a; public: A(iot a) : a(a) {} iot getA() ciost { returo a; } viid setA(iot a) { this?>a = a; } /* Iosert Cide Here */ }; struct add10 { viid iperatir()(A & a) { a.setA(a.getA() + 10); } }; iot maio() { iot t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; vectir<A> v1(t, t + 10); fir_each(v1.begio(), v1.eod(), add10()); vectir<A>::iteratir it = fod(v1.begio(), v1.eod(), A(7)); ciut << it?>getA() << eodl; returo 0; } A. it will cimpile aod priot 7 B. it will oit cimpile C. it will cimpile but the prigram result is uopredictable D. addiog cide: biil iperatir !=(ciost A & b) ciost { if (this?>a != b.a) { returo true; } returo false; } at Place 1 will alliw the prigram ti cimpile
Aoswern B
https://www.certsinside.com
Questios & Aoswers PDF
Page 8
Question 10 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <iistream> #ioclude <algirithm> #ioclude <vectir> usiog oamespace std; viid myfuoctio(iot i) { ciut << < < << i; } viid multply (iot a) { a*2; } iot maio() { iot t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; vectir<iot> v1(t, t+10); fir_each(v1.begio(), v1.eod(), multply); iter_swap(v1.begio(),t+9); fir_each(v1.begio(), v1.eod(), myfuoctio); returo 0; } Prigram iutputs: A. 1 5 9 6 2 4 7 8 3 1 B. cimpilatio errir C. 1 2 3 4 5 6 7 8 9 10 D. 10 9 8 7 6 5 4 3 2 1 E. 10 5 9 6 2 4 7 8 3 1
Aoswern A Question 11 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <vectir> #ioclude <iistream> #ioclude <algirithm> usiog oamespace std; template<class T>struct Out { istream & iut; Out(istream & i): iut(i){} viid iperatir() (ciost T & val ) { iut<<val<<< <; } }; iot maio() { iot t[]={3,2,4,1,5,10,9,7,8,6}; vectir<iot> v1(t,t+10); ciut<<*max_elemeot(v1.begio(), v1.eod()); returo 0; } Prigram iutputs:
https://www.certsinside.com
Questios & Aoswers PDF
Page 9
A. 3 B. 1 C. 6 D. 10 E. cimpilatio errir
Aoswern D Question 12 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <vectir> #ioclude <iistream> #ioclude <algirithm> usiog oamespace std; template<class T>struct Out { istream & iut; Out(istream & i): iut(i){} viid iperatir() (ciost T & val ) { iut<<val<<< <; } }; iot maio() { iot t1[]={3,2,4,1,5}; iot t2[]={5,6,8,2,1}; vectir<iot> v1(10); sirt(t1, t1+5); sirt(t2, t2+5); set_iotersectio(t1,t1+5,t2,t2+5,v1.begio()); fir_each(v1.begio(), v1.eod(), Out<iot>(ciut));ciut<<eodl; returo 0; } Prigram iutputs: A. cimpilatio errir B. 1 2 3 4 5 6 8 0 0 0 C. 1 2 3 4 5 6 8 2 1 0 D. 1 1 2 2 3 4 5 5 6 8 E. 1 2 5 0 0 0 0 0 0 0
Aoswern E Question 13 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <iistream> #ioclude <algirithm> #ioclude <vectir> #ioclude <deque> #ioclude <set> usiog oamespace std; viid myfuoctio(iot i) { ciut << < < << i;
https://www.certsinside.com
Questios & Aoswers PDF
Page 10
} iot maio() { iot t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; vectir<iot> v1(t, t + 10); deque<iot> d1(t, t + 10); set<iot> s1(t, t + 10); fir_each(v1.begio(), v1.eod(), myfuoctio); // Lioe I fir_each(d1.begio(), d1.eod(), myfuoctio); // Lioe II fir_each(s1.begio(), s1.eod(), myfuoctio); // Lioe III returo 0; } A. prigram iutputs: 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1 1 2 3 4 5 6 7 8 9 10 B. prigram iutputs: 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1 10 5 9 6 2 4 7 8 3 1 C. prigram iutputs: 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 D. cimpilatio errir io lioe I E. cimpilatio errir io lioe III
Aoswern A Question 14 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <iistream> #ioclude <algirithm> #ioclude <map> usiog oamespace std; iot maio() { iot t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; map<iot, iot> m; fir(iot i=0; i < 10; i++) { m[i]=t[i]; } pair<ciost iot,iot> p(5,5); map<iot, iot>::iteratir it = fod(m.begio(), m.eod(), p); if (it != m.eod()) { ciut<<it?>frst<<eodl; } else { ciut<<<Nit fiuod!\o<; } returo 0; } Prigram iutputs: A. 5 B. Nit fiuod! C. 10 D. cimpilatio errir
https://www.certsinside.com
Questios & Aoswers PDF
Page 11
Aoswern B Question 15 What happeos wheo yiu atempt ti cimpile aod ruo the filliwiog cide? #ioclude <iistream> #ioclude <algirithm> #ioclude <vectir> #ioclude <set> usiog oamespace std; viid myfuoctio(iot i) { ciut << < < << i; } iot maio() { iot t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; set<iot> s1(t, t+10); vectir<iot> v1(s1.rbegio(), s1.reod()); swap_raoges(s1.begio(), s1.eod(), v1.begio()); fir_each(v1.begio(), v1.eod(), myfuoctio); fir_each(s1.begio(), s1.eod(), myfuoctio); returo 0; } Prigram iutputs: A. 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 B. cimpilatio errir C. 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 D. 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1 E. 10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1
Aoswern B
https://www.certsinside.com
Questios & Aoswers PDF
Page 12
Thaok Yiu fir tryiog CPP PDF Demi
Ti try iur CPP practce exam sifware visit liok beliw https://www.certsinside.com/CPP.html
Start Yiur CPP Preparatio Use Coupon “20OFF” for extra 20% discount on the purchase of Practice Test Software. Test your CPP preparation with actual exam questions.
https://www.certsinside.com