Which of the following accesses a variable in structure *b?
Which of the following is a properly defined structure?
What is the output of this program?
1. #include2. using namespace std; 3. struct sec { 4. int a; 5. char b; 6. }; 7. int main() 8. { 9. struct sec s ={25,50}; 10. struct sec *ps =(struct sec *)&s; 11. cout << ps->a << ps->b; 12. return 0; 13. }
What will be the output of this program?
1. #include2. using namespace std; 3. int main() 4. { 5. struct ShoeType { 6. string style; 7. double price; 8. }; 9. ShoeType shoe1, shoe2; 10. shoe1.style = "Adidas"; 11. shoe1.price = 9.99; 12. cout << shoe1.style << " $ "<< shoe1.price; 13. shoe2 = shoe1; 14. shoe2.price = shoe2.price / 9; 15. cout << shoe2.style << " $ "<< shoe2.price; 16. return 0; 17. }
What is the output of this program?
1. #include2. using namespace std; 3. struct Time { 4. int hours; 5. int minutes; 6. int seconds; 7. }; 8. int toSeconds(Time now); 9. int main() 10. { 11. Time t; 12. t.hours = 5; 13. t.minutes = 30; 14. t.seconds = 45; 15. cout << "Total seconds: " << toSeconds(t) << endl; 16. return 0; 17. } 18. int toSeconds(Time now) 19. { 20. return 3600 * now.hours + 60 * now.minutes + now.seconds; 21. }