Skip to main content

CS201 Current Midterm Paper Fall 2013 Questions Answers



using namespace std;

int main() {

int a[6]={2,1,3,15,20,50};
int i=++a[1];
int j=a[1]++;
int k=a[i++];
int l=a[--i]*i;
int m=a[++i]-1;
couti" "j" "k" "l" "m" ";

    return 0;
}
output
3  2  3  6  14

2. Bitwise operators to mention
&  =bitwise AND operator
 | =btwise OR operator
    ^ =bitwise Exclusive OR operator
   ~ =bitwise NOT operator
3. 
int A[5] = {1 , 2, 3, 4};
int i;
for (i=0; i<5; i++)
{
A[i] = 2*A[i];
Cout<< A[i] " ";
}
output
2   4   6   8   118
4.
What will be the output of the following; (5 marks)
void main()
{
union Num
{
int ValueI;
float ValueF;
double ValueD;
char ValueC;
};

Num TestVal = {100};
cout"Integer =" TestVal.ValueIendl;
TestVal.ValueF = 2.123;
cout "Float=" TestVal.ValueFendl;
cout"Uninitialzed double =" TestVal.ValueD endl;
cout"Some rubbish???"endl;
TestVal.ValueC = 'U';
cout"character=" TestVal.ValueCendl;
}
output
Integer = 100
Float= 2.123
Uninitializad double 5.30754e-315
Some rubbish???
Character = U
5.
#include <iostream.h>
main ()
{
int y[10] = {10,20,30,40,50,60,70,80,90,100};
int *yptr, i;
yptr = y;
cout*(yptr+1*2)endl;
}
output
30


    Q) what will be the Out put of
    int x=10;
    int y=30;
    int *xptr;
    xptr=&x;
    cout "x = " *xptr+x ; (Out put signs are present but cant write here )
   Answer:   x=20
Q))When a pointer is incremented then how many bytes will it move to change its address?  Ans:When a pointer is incremented, it actually jumps the number of memory addresses
►According to data type (Pg 160)
“If an integer occupies four bytes in the memory, then the yptr++; will increment its value by four. when we increment the yptr, it
points to the next integer in the memory”
It depends on the data type of the size. *ptr++ this pointer will point to the next element in the array.
  Q 3 : If ( char array [7], is a character array then write a char at fifth loction of this array.
char[4]=’a’;


Q 4 : Which function is used in  read & write while handling file.

ifstream inFile; // object for reading from a file
ofstream outFile; // object for writing to a file
1:intPtr  is  a  constant pointer to integer  155
int *const  intPtr= &x;
       2:intPtr  is  a  pointer  to  constant 
const  int *intPtr = &x;
q3:  Char  name []= " Hello  World";   
    size  of  array name ?
ans :12  including space and NULL character
double atof (const char *nptr)
Answer: page 191
Converts the string nPtr to double.
char *strcpy (char *s1,const char *s2)
Answer: page 192
Copies string s2 into character array s1. The value of s1 is returned.


q5  tel  the size  of  initialized  array
int  arr []={0,0,0,0}
ans: 4
--We are trying to open a txt file which does not exist with command (“myfile.txt”, ios::out);  (2 marks)
 Ofstream.out;
Out.open(“myfile.txt”, ios::out);
If(!out) { cout<<”not found”; exit(1);}
A new file will be created and now we have to add our data in this file.

---A two-dimensional array has 2 rows and 3 columns. Write down the syntax to initialize first element of all rows of two-dimensional array with value 3 (2 marks)
int num[2] [3] ;
num[0] [0] =3;
num[1] [0]=3 ;
num[2] [0]=3 ;

Q)) When a pointer is incremented,what happens in the following cases?page#172
a)single-dimensional array
b)two –dimensional array 3

Comments

Popular posts from this blog

CS301 Current Finalterm Paper Spring 2014 Shared By M. Waleed

My Tday's Cs301 Paper: Mcq's Are From Moaz And Some Are From Handouts. Subjective Is From Moaz Majority One. 1- The Image Segmentation Define? 2- The Maximum Number Level Of Nodes In Binary Tree 3-The Iteration Array Have To Sort. 4- The Hapified Array Have To Solved 5- The Algorithm Of Binary Seaoh Tree 6-Sara Arrays Wala He Tha Ya Heap Wala. 7-....Wala Wala Wala...

CS614 Quiz No.3 Shared by Students (Solved), Spring 2014

______ index stores first value in each block in the sequential file and a pointer to the block.  Select correct option:   Dense  Sparse  B-Tree  Hash In context of data parallelism, the work done by query processor should be:  Select correct option:  Almost zero  Maximum  Pipelined  Filtered across partitions The optimizer uses a hash join to join two tables if they are joined using an equijoin and  Select correct option:   Outer table has less number of rows  Inner table has less number of rows  Cardinality of tables is equal  Large amount of data needs to be joined Bitmap index is appropriate for:  Select correct option:  Low cardinality data  High cardinality data  Clustered data  Aggregated data If a task takes “T” time units to execute on a single data item, then execution of this task on “N” data items will take __...

CS614 Quiz No.4 Shared by MT Khan (Solved)

Question # 1 of 10 ( Start time: 09:04:39 PM ) Total Marks: 1 A typical cycle of implementing the change in DWH comprises of the sequence: Select correct option: Production -> QA -> Development Development-> QA -> Production(CORRECT) Development -> Production -> QA Production -> Development -> QA Question # 2 of 10 ( Start time: 09:05:16 PM ) Total Marks: 1 Vertically wide data means: Select correct option: Dataset has large no. of attributes Dataset has large no. of records(CORRECT) Dataset has attribute skews Dataset has partitioning skews Question # 3 of 10 ( Start time: 09:05:43 PM ) Total Marks: 1 In ___________ phase of kimballs approach, we identify the components needed now and in future. Select correct option: Requirement definition Architectural design Product development Analytical application development Question # 4 of 10 ( Start time: 09:06:56 PM ) Total Marks: 1 Technical architecture design supports the communicat...