Вы находитесь на странице: 1из 5

Delhi Public School Bangalore South

Class: 11
Subject: Computer Sc. Unit Test - 2 Max.Marks: 50
Date: 28/07/15 Duration:11/2 hrs

Instructions: 1. All the questions are compulsory.


2. Include corrected statements and reasons for “Identify errors” questions.
3. Include working in tabular form, for output questions.
4. Include functions for Type C questions, along with appropriate comments.

Type A 10 x 1= 10

1. Write the corresponding C++ expressions for the following mathematical expressions:

−𝑏±√𝑏2 −4𝑎𝑐
i) 𝑥=
2𝑎
3
ii) V = 4/3 Π r

2. Name the header files for the following function


i) fabs() ii) getchar() iii) isupper() iv) setprecision()
3. Write the order of evaluation for the following expression:
int i= 12, j=20, k=7, result
Result = 6 * i%5 * 9 + (j-3) / (k+1) && !(j>15)
4. How are the following statements different?
char pcode = 75;
char pcode=’k’;
5. Arrange the following operators in ascending order depending on their precedence of evaluation.
Logical operator, increment and decrement operator, comma operator, arithmetic operators
6. What is the result of y and m after execution of following expression:
y=((m=1, m*5), (m+=6, m/2))
7. Write a function declaration for a function: fun() ,that takes two arguments and returns a character. The first
argument is integer and is not to be modified. The second argument is float with a default value of 5.5.
8. int AreaCube(int length, int width = 25, int height = 1);
Do the following function calls given below execute successfully for the above declaration?
i) AreaCube(2,3) ii ) AreaCube()
9. Given the following function.
int fun(double);
Why will the following not work?
void func2()
{ int r;
r=fun(1, 2.0);
}
10. Differentiate between getchar() and cin.get(ch).

1
Type B 12 x 2 = 24
Identify syntax errors and correct them.
1. 2.
#include <iostream.h> #include<iostream.h>
float subtraction (int a=1, int b) int larger(int a, int b);
{ void main()
int r; {
r=a-b; int i, j, k;
return r; clrscr();
} i=9;
int main (); j=12;
{ k=larger(i,::j);
int x=5, z; cout<<k++ - ++sizeof(j);
const int y; getch();
z = subtraction (x,y); }
cout << "The result is " << z << '\n'; int &larger(int &a, int b)
cout << subtraction (7,2) << '\n'; {
z= 4 + subtraction (x); int m = a % b;
cout << z '\n'; (m+a>b) ? return a; return b ;
}
}

3. 4.
#include<iostream.h> #include<iostream.h>
#include<conio.h> #include<conio.h>
int& f1( const int k, int &r)
float fun( float x , int y) {
{ int n=k++ *r;
int p = 0; cout<<” the value of m =”<< n;
p = x + y – x + ++y; return r-- ;
cout<<p; }
q = (p == 6, p++, p+1)
cout<<--p; void main()
cout<< x-p << x * = p ++ n/ 3; {
return &p; int e = 3,f = 5,g = 6, h;
} char ch;
void main( ) cin>>ch;
{ cin>>h;
int a, b, m; h = (e>f>g) ? f1(e + ch, f) : f1(f, g);
m = ++a + (b)++ ; cout<< h;
int d = pow(a ,b*2, m); int m = +e == f-2? cout<<++x:cout<<e--;
cout<<f(d, c); cout<<m;
} return 0;
}

2
Find the output of the following :

5. 6.
#include<iostream.h> #include<iostream.h>
#include<conio.h> #include<conio.h>
#include<math.h> #include<iomanip.h>
#include<iomanip.h> void main()
float sum=0.0; {clrscr();
float calc(int &,int); int a=10,b=5,i=6;
void main() float sum=0;
{ sum= a++ + ++a - b++ + ++b;
clrscr(); int k=(a>b++ || ++a == b);
int a=(1,2,3); cout<<k<<" "<<sum<<"\n";
int b=3; cout<<++a<<" "<<b--<<" "<<b+a++;
float k=calc(a,b); getch();
cout.setf(ios::fixed); }
cout.setf(ios::showpoint);
cout<<a<<endl<<"k="<<setprecision(3)<<k;
getch();
}
float calc(int &a, int b=9)
{
const int r=3;
sum=pow(a,r)-b/++sum;
cout<<sum<<endl;
a++;
return sum;
}
7. 8.
#include<iostream.h> #include<iostream.h>
#include<conio.h> #include<conio.h>
#include<math.h> #include<iomanip.h>
int s=8; int x=0;
int tr(int); int f1();
int pt(int,int); void main()
void main() {
{ clrscr(); clrscr();
int s=5,m=4, n=7; int x=1, y=3,z=10,t;
float op=(s*s++)>!(m)? tr(m+s):pt(m,n);
cout<<op+s<<"%"; cout<<(x==1 && !z || sizeof(y)<z%2);
getch(); int k=(t=3,t+3,t=0,t+5);
} cout<<k;
int tr(int c) int l=f1();
{ cout<<l<<"\t"<<::x;
c=((c==10?1:0),5,c++); getch();
return c; }
}
int pt(int e,int f) int f1()
{ {
int r=!(e>5) && ((e*e)/f==sqrt(s)); int x=11;
return r; } return(x && !(::x),++::x); }
3
9. Compare call by value and call by reference methods.
10. Mention 2 applications for default and constant arguments, each.
11. Write advantages and disadvantages of comma operator.
12. Why is it not advisable to compare signed and unsigned values? Explain with an example.

Type C 4 x 4 = 16

1. Write a program to input a character and to convert accordingly and display the same
i) if it is an uppercase character then convert it into lowercase and print the next letter
ii) if it is a lowercase character then convert it into uppercase
iii) if character is not a letter then display message “not a letter”
2. Write a program to find the roots of a quadratic equation. (Verify all conditions)
3. Write a program to print Term 1 report card of a student by accepting marks obtained in FA 1, FA 2 and
SA 1. Calculate grades as given below:

Grade Marks Range Grade point


A1 91 -100 10.0
A2 81 - 90 9.0
B1 71 - 80 8.0
B2 61 - 70 7.0
C1 51 - 60 6.0
C2 41 - 50 5.0
D 33 - 40 4.0
E1 21- 32 3.0
E2 00 -20 2.0

Report Format
Student Details:
Name:
Class:
Roll:
Admission no:
Subject FA1 FA2 SA1 Term 1

Total Grade:

4
4. Write a program that reads the customer number and power consumed and prints the amount to
be paid by the customer. The unit charges are as given below:

Consumption Rate of
Units Charge
-------------------------------------------------------------------------------------------------
0-200 Rs.0.50 per unit
201-400 Rs.100 plus Rs.0.65 per unit excess 200
401-600 Rs.230 plus Rs.0.80 per unit excess of 400.
----------------------------------------------------------------------------------------------

Вам также может понравиться