0% found this document useful (0 votes)
50 views

2017 11 Usp Computer Science Set A

This document contains a C++ quiz with 4 questions covering topics like header files, functions, loops, parameters, strings and more. It provides code snippets and asks the student to identify errors, write corrected code, convert code between loops and switch statements, explain functions, and write programs to check palindromes, count text elements, and calculate powers. The student is given 1 hour to complete the 25 mark quiz.

Uploaded by

Uphar Jaiswal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

2017 11 Usp Computer Science Set A

This document contains a C++ quiz with 4 questions covering topics like header files, functions, loops, parameters, strings and more. It provides code snippets and asks the student to identify errors, write corrected code, convert code between loops and switch statements, explain functions, and write programs to check palindromes, count text elements, and calculate powers. The student is given 1 hour to complete the 25 mark quiz.

Uploaded by

Uphar Jaiswal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CLASS XI

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;
}

Q.2.a) Find the output of the following program. 3


#include<iostream.h>
void Withdef(int HisNum=30)
{
for(int I=20;I<=HisNum;I+=5)
cout<<I<<,;
cout<<endl;
}
void Control(int &MyNum)
{
MyNum+=10;
Withdef(MyNum);
}
void main()
{
int YourNum=20;
Control(YourNum);
Withdef();
cout<<Number=<<YourNum<<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;

b) Convert the following code segment into do-while loop. 2


#include<iostream.h>
void main()
{ int i;
for(i=1;i<=20;++i)
cout<<\n<<i;
}

c) Explain any two character functions with syntax and examples 2

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

You might also like