2nd year Computer science (ICS) Chapter 3 Object Oriented Programming using C++ for Grade-12 Khyber Pakhtunkhwa Board.
Object Oriented Programming using C++ for kpk board
Q.5) Pick that variable from the following list which is improperly declared and named. Also, describe the reason of its invalidity.
1) int sum;2) int cats=5, dogs=5;3) int my variable name;4) int void= 5;6) int 3some;7) int meters_of_pipe;8) int length , width=5;
Answer:Following are the variables which are improperly declared and named.
int my variable name;Reason:It is having the spaces between the names.int void= 5;Reason:Reserved or keywords cannot be used as the variable names.int 3some;Reason:A variable name starting with an integer is not valid.
Q.6) Write a C++ program to get six subject marks of a student and then calculate its total, average, and percentage and display them on screen.
Read more Oriented Programming Using C++