2017 11 Usp Computer Science Set A
2017 11 Usp Computer Science Set A
2017 11 Usp Computer Science Set A
Computer Science
Time : 1 hour Set - A M.M. 25
Q.1. Observe the following C++ code and write the name(s) of the header file(s), which will be
essentially required to run in a C++ compiler. 1
void main()
{
char text[20],c;
cin>>text;
c=tolower(text[0]);
cout<<c<<is the first char of<<text<<endl;
}
b. Find the error from the following code segment and rewrite the corrected code underlining
the correction made. 2
# include(iostream.h)
void main ( )
int X,Y;
cin>>>X;
for(Y=0,Y<10, Y++)
if X= =Y
cout<<Y+X;
else
cout>>Y; }
Q.3. a) Convert the following code segment into switch case construct. 3
int ch;
cin>>ch;
if(ch = = 1)
cout<< Laptop;
else if(ch = = 2)
cout<<Desktop ;
else if(ch= = 3)
cout<<Notebook;
else
cout<<Invalid Choice;
Q.4. a. Difference between formal parameter and actual parameter. Also give a suitable c++ code
to illustrate both. 3
b. Write a program to input a string from user and check string is palindrome or not. 3
c. Write a program to find the total number of characters and lines in a paragraph of
text 3
d. Write a program uses a function power() to raise a number m to power n. The function
takes int value for m and n and returns the result correctly. Use a default value of 2 for n to make the
function calculate squares when this argument is omitted. Write a main() to get the value of m and n
from the user and to display the calculated result. 3