Cs PDF
Cs PDF
1. (a) Name the header file to which the following belong : (2)
(i) setw() (ii) exp()
(iii) tan() (iv) getch()
(b) Illustrate the use of comments and indentation in a c++ program with the help of an example.
(2)
(c) Rewrite the following program after removing the syntactical error(s), if any.
Underline each correction. (4)
#include[iostream.h]
void MAIN()
{
int a=b=c=0;
cin>>a,b,c;
if a<b
cout>>a>>b>>c>>endl;
Else
cout<<d-a<<endl;
}
(d) Find the output of the following program : (2)
#include<iostream.h>
void main()
{
int x=3,y=5;
cout<< ++x << << y-- <<endl;
y+=6;
cout<< x-- << << ++y<<endl;
}
(f) Give use of cascading of insertion/extraction operators with the help of an example. (2)
1
(g) State valid/invalid for the following identifiers ,give reasons for invalidity : (3)
(i) 2roll (iv) S.I.
(ii) _111 (v) Date of Birth
(iii) default (vi) Del-Key
(h) State valid/invalid for the following literals ,give reasons for invalidity : (3)
(i) .54 (iv) \x67
(ii) computer (v) Technology
(iii) 13E-1.5 (vi) 5+3
(c) Write a C++ program to input a number. If the number is even and positive, print its square
root otherwise print its cube.(use conditional operator only) (3)
3. (a) Write an algorithm to check whether a given number is prime or not. (4)
(b) Write an algorithm to find the sum of the following series upto n terms: (3)
2 , 3 , 5 , 8 , 12, 17.
2
(c) Write a program to calculate and print the sum of the series :
1 + x2 + x4 + x6 +..upto n terms (3)
(d) Write a program to input a month number and print it in words (1-January, 2-February etc.)
(3)
4. (a) Write a program to display the first n terms of the Fibonacci series. (4)
(c) Find the output obtained by the following statements. Also write a for loop
for obtaining the same output : (4)
int val=2;
cout<<val-1<<endl<<val+1;
val+=3;
cout<<endl<<val++<<endl;
cout<<++val<<endl;
*******************