Cs201 Midterm Subjective by Adil Alvi
Cs201 Midterm Subjective by Adil Alvi
Cs201 Midterm Subjective by Adil Alvi
Q19: marks 3
Int num[3][2]={12,51,34,54,14,55};
For(int j =0; j<3; j++)
Cout(*(*num+j)+1)endl;
Q20: marks 3
A=3;
B=a++;
Cout"a="a;
Cout"b="b;
Q21: (marks 5) Write a code to read a string not greater than 20 character from keyboard, store it
in on array and display it on screen.
Q22: (marks 5) calculate the area of circle. You have to declare two variables for this, one is area
and other is radius. Take the value of radius from user. Hint: Area of circle= 3.14 *radius *
radius
Q23: (marks 5) Write a program that prompts the user to enter a string & reverse the string using
pointer & display the string in reverse order on the output screen. Program must include the
complete line include spaces.
Jun 11, 2017
1) Float array[8] declare krni the and then pointer pas krna tha.
2) Utilty software kounsy hoty hn example.
3) Net salary caluculate krni the c++ program likh kr dailywages= 1000 aur no of days. Khud
write krny thy salary= dailywages*no of days.
4) String declare krni the "this is my country"
5) Program. M, n values batani the after execution of program.
Jun 11, 2017
1) Write 2d array with five rows and six column and also write pointer to above array.?
2) Why we comment liberally in programs does they affect on performance...?
3) A do while loop executive how many times at least and a while loop?
4) Then 2 program likhi thy inline output likhi thy
5) One question was from Array
6) Write down the general syntax of switch statement.
7) Write a code segment that displays the diagonal element of a matrix of nxn.
8) Where N can be any number and represents dimension of matrix
9) Mention any two affects in a program who can occur as a result of an overflow condition.
Q1: can we create an array of object for a class having default constructor?
Q2: overloaded member function using ostream and istream show any example?
Q3: write c++ code to overload subscript [] operator for string class?
Q4: what does you meant by static data member in c++:
Q5: explain the terms predecrenent and post decrement?
Jan 13, 2015
Q1. Data Reading From Files, Write Code to read data from myfile.txt, and write 1 line on 100
location of file by using fstream functions (Lecture 18) (5 Marks)
Q2. Swapping & Call by Reference, Pointers, Given Code to Write Output (5 Marks)
Q3. Functions and structures, how to handle members with two different technique (Lecture 18)
(3 Marks)
Q4. String concatenation, Given Code to Write Output (Lecture 17) (Marks 2)
Q5. Size of () & Array, Given Char Array to Find out Output by using Size of (Lecture 20)
(Marks 2)
Jun 11, 2014
1) Write a program with counts which tells at the end how many numbers are in the string
"90some7text". The output should be like. The total nos are: 3
2) Write a program declare a string of 10 characters and then show the value of the 4th and 8th
element using pointers?
Q 1: Identify each of the given functions as string conversion function or string manipulation
function.
(i) double at of (const char* nptr)
(ii) char* strcpy (char*s1 const char*)
(iii) int at of (const char*nptr)
Q 2 : If p and q are pointers and n is integer then the following are legal or illegal.
A p + q. B p - q. C p + n. D p – n. E n + q
Q 3: If (char array [7], is a character array then write a char at fifth location of this array.
Q 4: Which function is used in read & write while handling file.
Dec 22, 2013
1. Write a structure named inventory which has char array, int name and int Num 3 Marks.
2. Syntax to close a file which has handle my file. 2 Marks
3. Code consisting of calling an array by a function and how function call change array contents.
5 Marks.
4. Const pointer related question. 2 Marks
Jun 4, 2013
For getting good marks is cs201 prepare multidimensional array ,array and pointer and string and
file handling or structure union and bit wise manipulation k topic achy se ready karlo
May 16, 2012
1) Write a declaration statement for an array of 10 elements of type float. Also initialize first four
elements of array to 1.0, 2.0, 3.0 and 4.0.(2)
2) Which bitwise operator returns true if both bits are different and returns false if both bits are
same?(2)
3) Suppose if we want to store values like 10, 45.3, 4, A, D, 6.4, and 50 by using array. Can we
store all these vu solutions dot com elements by declaring a single array? Yes or no? Give reason
to support your answer(3)
4) Write the code for a structure called Inventory having the following elements:
(i) A character array named part name
(ii) An integer named part number
(iii) An integer named stock. (3)
5) Write a program which opens a file named “this.txt” and then using write() function, writes
the string “Introduction to Programming” at the end of the file.(5)
6) Write a program which declares and initializes an integer array of 10 elements and then using
a pointer, displays the array elements in reverse order.
May 13, 2012
1) *num and num& difference.
2) Which one will you prefer: random or sequential access .Reason?
3) A code snippet was there of strings to calculate bytes
4) Cin function to compare two strings
1) Write a short note on files and also explain how they are handled in C++?
2) Is comparison possible in pointers? If yes what operators are used, if no justify your answers?
3) Briefly explain structure padding?
4) What is the difference between single and multi-dimensional arrays?
5) Explain the meaning of given C++ statement: const int *ptr = &x;
6) Write about char str?
May 14, 2011
1) If there are 2n elements in an array then what would be the number of iterations required to
search a number using binary search and linear search?
2) Which header file must be included while handling files?
3) What is meant by C++ statement: const int *ptr = &x;
(i) An array day is declared as: int day[] = {1, 2, 3, 4, 5, 6, 7}; How many elements does array
'day' has?
(ii) If the declaration is changed as: int day[7] = {1, 2, 3, 4, 5, 6, 7}; How many elements does
array 'day' has?
4) Write a void function( ); that takes integer numbers from the user and then displays the sum of
odd and even numbers entered by the user. Your program should terminate if user enters a
negative number
5) Write down the function definition if we want to pass the arguments to a function by reference
without changing the values stored at that addresses.
6) What is meant by scope of identifiers? Differentiate between different scope of identifiers and
explain them with examples?
7) Can you use an assignment operator to assign the value of one C-string to another?
8) Which bitwise operator returns true if both bits are different and returns false if both bits are
same?
9) What will be the value of x after the execution of the following code segment?
Int x =10;
int y =30;
int *xptr = &x;
x = *xptr + 10;
10) Write a program which reads a text file “playersinfo.txt” residing in the current directory.
Open the file playersinfo.txt in read mode and assign these values to the struct Player; assume
order of the data in the file to be exactly the same as the order of struct attributes. The struct
Player has following attributes
i) Name
ii) Height
iii) Age
iv) Score
v) Game
After reading the file and assigning values to the struct, in the end close the file playersinfo.txt
11) Write a recursive function that takes character array and starting subscript as arguments. In
each recursive call, the function should display the string from subscript to the end of string. The
starting subscript in first call should be 0. In each successive call, the subscript should increase
by one and function should print the array from subscript to the end of string. The function
should stop processing and return when null character encounters. Suppose the char string passed