Saturday, 9 June 2018

Computer Science IX & XII Question Bank


Dear Students,

ATS provides the better way of Program Learning with experienced faculties of engineering colleges and Industry Experts. Our team emphasis on the programming concepts with practical implementations. Some sample program problems of C++ under subject Computer Science of class XI & XII are given below for your practice and Expertise. You can bring the solution of any program given below from the branch of ATS. We assign these programs as problem assignments to our students and they perfom in front of faculties and get the practical exposer.  

1.     Write a program to calculate number of vowels (a, e, i, o, u) separately in the entered string.

2.     Write a program to find the power of number using function.

3.     Draw a flowchart to print the factorials of numbers from 1 to n, where n is entered by user.

4.     Write a program to copy a file into another file.

5.     Write a function to print the sum of the following series: 1 + 22 + 33 + … + nn  where n is passed as an argument to the function.

6.     Write a function to read a two dimensional matrix along with the number of rows and columns in it, from the user.

7.     Write a program that displays the recommended actions depending on the color of a traffic light using the switch statement.

8.     Write a program having a recursive function to calculate the factorial of a number. In the main() function, read the value of the number and then using the recursive function display the result.

9.     Write a program to create a structure Employee having empCode, name, and department, address and salary as its members. Read the details for 10 employees and then display them.

10.  Define the structure of a node of a singly linked list and use it to write a function to count the number of nodes in a singly linked list. The function should accept a pointer to the first node of the list and it should return the number of nodes in the list.

11.  A Lucas sequence is given below: 1, 3, 4, 7, 11, 18, 29   The third number is sum of previous two numbers. Write a program to print first 10 numbers of Lucas sequence.

12.  Write a program to print the value of numbers in words when number entered is in the range of 0 to 999.

13.  Write a program to print only first 12 characters including blank space from file test.txt.

14.  Define a structure Time having integer data members hour, minute, second. Write a program to enter two variables of the type Time and then add these two variables and store the result into third variable. Also validate the second and minute of the result and print it.

15.  A, B and C are three 3x3 matrices containing real elements.

a) Write a  function to input from user appropriate values into matrices A and B. Use suitable loops. Make use of pointers if necessary.

b) Write a function to calculate matrix C such that C=A+B Use suitable loops. Make use of pointers if necessary

c) Write a program to call the above two functions and print Matrix C suitably. Write suitable prototype etc. Use suitable loops. Make use of pointers if necessary

16.  Develop a function to calculate sum of n even integers starting from a given even integer.

17.  Write a program to find the minimum of the 8 floating point numbers and its place in the array.

18.  Write an interactive program to evaluate the series: 1 – 1/2 + 1/3 – 1/4 …±1/n, where n is entered from keyboard.

19.  Write a program to calculate the electricity bill using if..else if, as per the following details

-  Given the number of units consumed, unit charges are as follows:

i) For first 50 units Rs. 0.50/unit

ii) For next 100 units Rs. 0.75/unit

iii) For next 100 units Rs. 1.20/unit

iv) For unit above 250 Rs. 1.50/unit

-         Add fuel surcharge 20% and Govt. Tax 10% on bill to calculate the total bill.

20.  Write a C++ function that converts a 2-digit octal number into binary number and prints the binary equivalent.

21.  Write a C++ program, which reads one line at a time from the disk file TEST.TXT, and displays it to a monitor. Your program has to read all the contents of the file. Assume the length of the line does not exceed 70 characters.

22.  Write a function to count the number of blanks present in text file named “PARA.TXT”;

23.  Write a Program to write and read a structure using write() and read() function using a binary file.





Find the OUTPUT/ERRORS

1. What is wrong with the following while loops ( ans how does the correct ones look like):

(i) int counter =1;                       (ii) int counter =1;

while (counter<100)                    while (counter <100)

{                                       cout<<counter<< “\n”;

  cout<<counter<<”\n”;                  counter + +;

  counter--;

}

2. Find the errors in the following program. State reasons:






 

#include<iostream.h>

class A

{      int a1;

public:      int a2;

protected:   int a3;

};

class B: public A

{

public:

void func()

{      int b1,b2,b3;

b1=a1;

b2=a2;

b3=a3;

}

};

class C: A

{

public:

void f()

{      int c1,c2,c3;

c1=a1;

c2=a2;

c3=a3;

}

};

int main()

{      int p,q,r,i,j,k;

B 01;

C 02;

p=01.a1;     q=01.a2;

r=01.a3;     i=01.a1;

j=01.a2;     k=01.a3;

return 0;

}

1.    Identify and explain the error(s) in the following code segment :


ATS-Bright students

 

float a[] = { 11.02, 12.13, 19.11, 17.41};

float *j, *k;

j = a;

k = a + 4;

j = j * 2;

k = k / 2;

cout << “ *j = “ << *j << “, *k = “ << *k << “\n”;

2.    Identify and explain the error in the following program :

#include<iostream.h>

int main()

{

int x[] = { 1, 2, 3, 4, 5 };

for (int i = 0; i < 5; i++)

{

cout << *x;

x++;

}

return 0;

}

3.    Give the output of the following :



char *s = “computer”;

for (int x = strlen(s) – 1; x >= 0; x--)

{

for(int y =0; y <= x; y++) cout << s[y];

cout << endl;

}

4.    Identify the syntax error(s), if any, in the following program. Also give reason for errors.


ATS-Bright students
 




void main()

{

const int i = 20;

const int * const ptr = &i;

*ptr++;

int j= 15;

ptr = &j;

}

5.    What will be the output of following program ?

#include<iostream.h>

void main()

{

char name1[] = “ankur”;

char name2[] = “ankur”;

if (name1 != name2)

cout << “\n both the strings are not equal”;

else

cout << “\n the strings are equal”;

}



6.    Give and explain the output of the following code :

void junk (int, int *);

int main()

{

int i = 6, j = -4;

junk (i, &j);

cout << “i = “ << i << “, j = “ << j << “\n”;

return 0;

}

void junk(int a, int *b)

{

a = a* a;

*b = *b * *b;

}

And so many programs you can learn from our team, we emphasis on the programming skill performance. You can bring your skills to us for more sharpness.

Thanks and Happy Coding……..

Regards:             

ATS-Team of Development and Performers.                      



2 comments:

  1. Thank you for sharing valuable information. Nice post. I enjoyed reading this post. The whole blog is very nice found some good stuff and good information here Thanks
    Home Tutors in Delhi | Home Tuition service

    ReplyDelete
  2. Nice blog, it's so knowledgeable, informative, and good looking site. I appreciate your hard work. Good job. Thank you for this wonderful sharing with us. Keep Sharing.
    home tutor in Allahabad | Home Tutor in Allahabad

    ReplyDelete