Computer Science Assignment Xi
Computer Science Assignment Xi
ASSIGNMENT
CLASS XI
Session 2018-19
Chapter 1: Computer Overview
2. What purpose does the operating system serve to the computer and the user ?
6. List two reasons why the scheduling of processes and threads on a multi-processor system
7. What are language processors. Explain the different types of language processors.
12. Convert the following decimal numbers to 10-bit : (a) 75 (b) 314 (c) 2048
binary : (d) 25,619 (e) 4095
(a) 37.31 (b) 6.215 (c) 33.333
Session 2018-19
5. List three devices that are contained inside the computer case.
6. List at least three components that allow the processor to communicate with other
devices.
Will be the sizes of following constants : '\a', "\a", "Reema\'s", ' \ " ' ?
Differentiate between a Logical Error and Syntax Error. Also give suitable examples
of each in C++.
WAP to enter three numbers and display their sum and average.
Session 2018-19
Chapter 7: Data Handling
1. What are data types ? What are all predefined data types in C++ ?
3. What are data type m o d i f i e r s ? How do they affect a base data type ?
on your own.
9. Write a C++ program that inputs experience and age of a person. The salary of
the person is 6000 if the person is experienced and his age is more than 35,
otherwise if the person is experienced and his age is more than 28 but less than 35
than the salary should be 4800 otherwise for experienced person the salary
should be 3000 and for inexperienced person the salary should be 2000.
10. A computer programming contest requires teams of 5 members
each. Write a program that asks for the number of players, and
then give the number of teams and number of players left over.
11. The value of e is known to be 2.71828 Using this value, write a program to
determine the value of the
t
expression : 2 - ye + 4Y. Obtain value of y from user.
12. Write a program which will raise any number X to a positive power n. Obtain
values of x and n from user.
13. Write a C++ program to input principal amount : and time. If time is more than
10 years, calculate the simple interest with rate 8%. Otherwise calculate it
with rate 12% per annum.
14. Write a C++ program to input a number. If the number is even, print its
square otherwise print its cube.
15. Write a C++ program to input a number. If the : number n is odd and positive,
print its square root otherwise print n5.
Session 2018-19
Chapter 9: C++ As per Latest C++11 Standards
What is the difference between entry control loop and exit control loop.
Find the sum of all the odd and even numbers separately between 1 to that number.
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
1 3 5 7 9 11 13 15 17 19
1 2 4 7 11 16 22 29 37 46
1 3 7 13 21 31 43 57 73 91
0 1 1 2 3 5 8 13 21 34
1 55555
22 4444
333 333
4444 22
55555 1
11111 12
2222 123
333 1234
44 12345
*
**
***
****
*****
*
***
*****
*******
*********
AB
ABC
ABCD
ABCDE
1 + X + X2 + X3 + X4 +……………..Xn
½ + ¾ + 5/6 + ………………….N/(N+1)
Session 2018-19
Chapter 11: Functions
What is a function.
Explain the different types of functions.
Define function prototype, function call and function definition.
What are the ways to define a function.
What is the difference between call by value and call by reference.
How a function returns a value.
What are the ways to pass arrays to a function.
Difference between the formal parameters and actual parameters. Also, give a
suitable C++ code to illustrate both
What is the difference between global and local variable.
Write a C++ function that converts a 2-digit octal number into binary number and
prints the binary equivalent.
Write a function called zero_Small( ) that has two integer arguments being passed by
reference and sets smaller of the two numbers to 0. Write the main program to access
this function.
Give the output of the following program :
#include<iostream.h>
in t g =2 0 ;
void func(int & x, int y)
{ x=x-y;y=x*10;
cout << x « ' , ' < < y << '\n';
}
void main()
{
intg=7;
func(g, ::g) ;
cout << g « « : : g < < '\n';
func (:: g, g) ;
cout << g « << g << '\n';
Raising a number n to a power pis the same as multiplying n by itself p times. Write a
function called power that takes two arguments, a double value for nand an int value
for pond returns the result as double value. Use default argument of 2 for p, so that if
this argument is omitted that number will be squared. Write the main function that gets
value from the user to test power function.
Write a C++ program that checks whether the given character is alphanumeric or a
digit. Add appropriate header file.
Write a C++ program that checks whether a given character is an alphabet or not. If
it is an alphabet, whether it is
lowercase character or uppercase character ? Include required header files
Write a C++ program that reads a string and converts it to uppercase. Include
required header files.
Write a C++ program that reads two strings and appends the first string to the second.
For example, if the first string is entered as Good and second string as Morning, the
program should print MorningGood. Use string library header.
Write a C++ program that reads two strings and copies the smaller string into the
bigger string. Use functions from string library header.
Write a function that takes one character as input and prints out that character plus
the next five characters, separated by tabs. The function takes one char argument,
and returns a char.
For example, if the value of the argument passed to the function was 'm', then the
function would print :
m n o p g r and return 'r'. Show separately the function declaration, the function
definition, and a sample function invocation.
Session 2018-19
Chapter 12 : Arrays
1. How does the amount of storage (in bytes) depend upon type and size of an array ? Explain
with the help of an example.
2. How are strings manipulated in C++ ? Support your answer with examples.
3. What do you understand by two-dimensional arrays ? State some situations that can be easily
represented by two-dimensional arrays.
9. Write a function to receive an intarray, its size and a character '+' or '-'. By default, the
character should be '+'. For the character '+', the function returns the sum of positive numbers
stored in the array and for the character '-', the function returns the sum of negative numbers
stored in the array.
10. Write a program to pass an integer type of array and its size as a parameter to a function and it
performs the following operations.
If input array ARR contains
6 10 12 13 15 17 14 18 19 21
Then output array ARR should have the following elements.
10 6 13 12 17 15 18 14 21 19
11. Write a program to pass an integer type of array and its size as a parameter to a function and it
performs the following operations.
If input array ARR contains
6 10 12 13 15 17 14 18 19 21
Then output array ARR should have the following elements.
17 14 18 19 21 6 10 12 13 15
12. Write a program to pass an integer type of array and its size as a parameter to a function and it
performs the following operations.
If input array ARR contains
6 10 12 13 15 17 14 18 19 21
Then output array ARR should have the following elements.
21 19 18 14 17 15 13 12 10 6
13. Write a program to pass an integer type of array and its size as a parameter to a function and it
performs the following operations.
CLASS XI C++ 1
If input array ARR contains
6 10 12 13 15 17 14 18 19 21
Then output array ARR should have the following elements.
3 5 6 39 45 51 7 9 57 63
14. Write a program to pass an integer type of array and its size as a parameter to a function and it
performs the following operations.
If input array ARR contains
6 10 12 13 15 17 14 18 19 21
Then output array ARR should have the following elements.
21 6 10 12 13 15 17 14 18 19
15. Write a program to pass an integer type of array and its size as a parameter to a function and it
performs the following operations.
If input array ARR contains
6 10 12 13 15 17 14 18 19 21
Then output array ARR should have the following elements.
10 12 13 15 17 14 18 19 21 6
16. Write a program to pass an integer type of array and its size as a parameter to a function and it
performs the following operations.
If input array ARR contains
6 10 12 13 15 17 14 18 19 21
Then output array XYZ should have the following elements.
6 10 12 14 18 21 19 17 15 13
17. Write a program to pass an integer type of array and its size as a parameter to a function and it
performs the following operations.
If input array ARR contains
6 10 12 13 15 17 14 18 19 21
Then output array XYZ should have the following elements.
6 10 12 14 18 13 15 17 19 21
18. Write a program which takes an integer type of 2-D array and its size as a parameter and
perform the following operations.
1. Sum of both the diagonal elements separately.
2. Sum of both the diagonal elements.
3. Sum of each row
4. Sum of each column
5. Display the diagonal elements at their respective positions.
6. Display the alternate elements.
7. Display the elements residing at edges of the array.
8. Display the elements residing at the corner of the array.
9. Swap the first and last row.
CLASS XI C++ 2
10. Swap the first and last column.
11. Display the prime elements only.
12. Display the elements containing 3 as its ones place.
13. Display the middle row and middle column only at their respective places.
14. Display both the upper half diagonal elements
15. Display both the lower half diagonal elements
16. Display the transpose of the matrix(2 – D array)
19. Write a program that adds two matrices X and Y of size R1 X C1 and R2 X C2 respectively.
20. Write a program that subtracts two matrices X and Y of size R1 X C1 and R2 X C2
respectively.
21. Write a program that multiply two matrices X and Y of size R1 X C1 and R2 X C2
respectively.
22. Write a short program that doubles every element of a matrix A [4] [4].
23. Write a Program to pass a string as a parameter to a function and perform the following
operations.
1. count total number of characters in that string or calculate length of a string without using a
library function
2. count total number of spaces in that string.
3. count total number of alphabets, digits, spaces, other characters and words.
4. count number of words “do” or “DO” or “Do” or “dO” present in that string.
5. Reverse each word and display the whole string.
6. Program to reverse a string.
7. Check whether the string is palindrome or not.
24. Write a program to count number of occurrences of a given character in a string.
25. Write a program to compare two strings for equality.
26. Program, to find -the position of a pattern string in main string.
27. Program to find a substring of a given string
28. Write a function to receive an int array, its size and a character '+' or '-'. By default, the
character should be '+'. For the character '+', the functionreturns the sum of positive numbers
stored in thearray and for the character '-', the function returns the sum of negative numbers
stored in the array.
CLASS XI C++ 3
Session 2018-19
What is the purpose of using a typedef command in C++ ? Explain with suitable
example.
How are following related to one another : (i) arrays and structures (ii) structures and
classes ?
WAP to enter the information of 10 students and display the information of the
WAP to enter the information of 10 students and display the information of the
WAP to enter the information of 10 students and display the information of the
WAP to enter the information of 10 students and display the information of the
Declare and initialize an array of 5 structures that store rollno, name and marks in 3
subjects for students
Assuming suitable data types, give necessary declarations for an array of 20 voter
records, each record of which consists of four data values viz. id-no, name,
address, age.
Make use of above declarations to write a program segment that prints id-no, name
for all those voters whose age exceeds 60
++B1.Height ;
Dimension(B1);
B3=B1;
++B3.Length ;
B3.Breadth++;
Dimension(B3);
B2=B3;
B2.Height += 5 ;
B2.Length-- ; Dimension(B2)
return 0 ;
}
Session 2018-18
Chapter 14: Programming Methodology
Explain the idea of a program bug. Do bugs always result from programming error ?
Justify your answer.
Explain how an expert understanding of your programming language can reduce
the amount of time in error rectification.
What is the significance of documentation ?
Why is program maintenance considered very important ?
What do you mean by robustness.