I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK 70. a) What is the difference between Hardware and Software? Give one example for each. b) Give two differences between primary and secondary memory. c) What is the use of operating system?. a) Convert the following expression into C++ expression : - i) b - 4 ac ii) x divisible by 9 and divisible by 8 b) Consider the following program segment and rewrite the program using switch -case statements. char category ; cin >> category ; if (category = = A ) if (category = = B ) cout << \n Group B ; if (category = = C ) cout << \n Group C ; cout << \n Group B ; cout<< Grade NIL ; c) Convert the following for loop into its equivalent while loop. for(int i=5; i >= ; i- -) cout<<i<< \n ; cout<< Over ; d) Convert the following while loop into its equivalent for. loop. int i=0,sum=0; while ( j < = 5 ) sum + = j ; j + = ;
e) Rewrite the following switch statement with if.. statement char direction ; cin>>direction ; switch(direction) case E : cout<< EAST ; case W : cout<< WEST ; case S : cout<< SOUTH ; case N : cout<< NORTH ;. a) Evaluate the following Boolean expression. a>c+b && ( a+c<d b+d >= a+c ) if a=4, b=, c=5 and d=. b) Give the output of the following program. int A = 7, B = 9 ; cout << ++A ; cout <<, ; cout << A++; cout << B-- <<, << --B; c) Evaluate the following :- x= a%b a* +b/a +0 where a=0 and b= d) Give the output of the following program segment:- void main() cout<< it is \train \to \new Delhi ; e) Give the output of the following program segment:- long n=456; int s=0, p=0; int x = n % 0; if ( x % == 0) p + = x * x * x; s + = x * x; n /= 0; cout << s <<, << p <<, << n << endl;
f) Give the output of the following program segment:- int a = 0, b =, c =, d =, e = 4, k = 0 ; while ( k < = 5) switch ( ++k ) case : a ++ ; case : b++ ; case : break case 4 : c + = ; case 5 : d ++; default : e- -; cout <<a <<","<< b<<","<< c <<","<< d<<"," << e<<"," << k ; g) Give the output of the following program segment:- void main( ) int j = 0 ; for(int i=0 ; i >=0 ; i+=) j + = i/; cout<<j<< ; h) Give the output of the following : - int i = 0, n = 0, sum = 0 ; do sum + = n + i i+= ; n - - ; while(i < = n); cout<<i<< <<n << " "<< sum ; 4. a) Rewrite the following program after removing the syntax error. x int ; float a, double b ; cin ( a, b ); x = a + b ; cout >> a >> b >> x ;
b) Rewrite the following program after removing the syntax error. int n, total = 0 ; cin >> n ; for ( int i = 0, i < n, i ++ ) j = ; do if j % = = 0 total + = j; j++; while (j <4 ) 5. a) Consider the following program and find required header files to execute the program. void main( ) int a, ch ; cin>> a >> ch ; cout<< a << ch ; getch ( ) ; b) An operator is used in between two values in conditional statement is know as c) What is entry control and exit control loop? d) Give an example of character constant and string constant. e) Explain the use of assignment arithmetic operator upon simple arithmetic operator with an example. f) Write the name of the following statements. i) A = 5 ii) A = = 5 g) What is the importance of break statement in switch statement? h) Write a alternative statement of the following :- if ( a > b ) x = a*a ; y = b*b ; i) A program is required to print all the even numbers between and 0. What type of statement is required to solve the program along with output statement? 6. a) Write a program to input two meter readings (current month and previous month) and perform the following operations :- Calculate consumed units CU= ( current month previous month readings) Calculate charges based on the following conditions :- Charges =.50 * CU if CU <=50 Charges =.70 * CU if CU >50 and <= 50 Charges =.80 * CU if CU >50 and <= 00 Charges =.90 * CU if CU >00 4
b) Write a program to calculate the sum of the following Series. + x / + x 4 / 5 + x 6 / 7 + x 8 / 9... upto n terms. c) Write a program to input n integers. Find the average of even numbers and average of odd numbers of the given numbers. d) Write a program to input a integer number and check whether the number is palindrome number or not. e) Write a program to check the number is prime or not. f) Write a program to print multiplication table for a given number by printing the table for 0 times. g) Write a program to calculate factorial of a given a number. h) Write a program to find the roots of a quadratic equation. 4 5