Question

C++ int num [ ] = { 1,2,3,3,4,5,6,7,8 } vector <int> vec (num, num + 8)...

C++
int num [ ] = { 1,2,3,3,4,5,6,7,8 }
vector <int> vec (num, num + 8) ;
vector <int> : : iterator iter ;
iter = vec . begin ( ) ;

Question 1. What is the result of execute the instruction num [4] ;?
a)2
b)7
c) unknown

Question 2. How many elements does the vector vec contain?
a)0
b)10
c)16
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Q1. A) Option : C

After executing the instruction num[4], nothing will happen. If you print the value by cout << num[4];. then 4 will be printed

Q2. A) No option is correct. Actually vector vec, contains 8 elements totally. Check the attached code

Hope this will clarify your doubts.Let me know, still if you have any queries..

Add a comment
Know the answer?
Add Answer to:
C++ int num [ ] = { 1,2,3,3,4,5,6,7,8 } vector <int> vec (num, num + 8)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT