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

CS504 Quiz No.3 Shared by Angel

Question # 1 of 10 ( Start time: 09:08:01 PM ) Total Marks: 1 Defining the services of an object means: Select correct option: What it does?        ok What it knows? Who knows it? Whome it knows? Question # 2 of 10 ( Start time: 09:08:27 PM ) Total Marks: 1 Which one of these represents the Krutchen’s 4+1 architectural view model? Select correct option: Logical view, Process view, Physical view, Development view, Use case view Logical view, Dynamic view, Physical view, Development view, Use case view Logical view, Process view, Physical view, Development view, Sequence view Dynamic view, Process view, Physical view, Development view, Use case view Question # 3 of 10 ( Start time: 09:09:50 PM ) Total Marks: 1 Return values in Synchronous messages are represented by: Select correct option: A solid line A dotted line with label        ok A solid line with label Double line Question # 4 of 10 ( Start tim...

CS302 Quiz No.4 Shared by Jawwad

Question # 1 of 10 ( Start time: 01:15:08 PM ) Total Marks: 1  Asynchronous mean that_____________  Select correct option:  Each flip-flop after the first one is enabled by the output of the preceding flip-flop  Each flip-flop is enabled by the output of the preceding flip-flop  Each flip-flop except the last one is enabled by the output of the preceding flip-flop  Each alternative flip-flop after the first one is enabled by Question # 2 of 10 ( Start time: 01:16:36 PM ) Total Marks: 1 A divide-by-10 ring counter requires a minimum of Select correct option: ten flip-flops five flip-flops four flip-flops twelve flip-flops Question # 3 of 10 ( Start time: 01:17:00 PM ) Total Marks: 1 When the number of states are reduced during the design any counter Select correct option: output changes and Input remain unchanged Input changes and output remain unchanged Input and output bith change Input and output remain unchanged Question # 4 of...

CS614 Quiz No.1 Shared by Manzar (UnSolved)

Question # 1 of 10 ( Start time: 03:35:24 PM )   Total Marks: 1 MDX by Microsoft is an example of _______ Select correct option: HOLAP DOLAP ROLAP None of the given options Question # 2 of 10 ( Start time: 03:36:40 PM )   Total Marks: 1 In decision support system ease of use is achieved by: Select correct option: Normalization Denormalization Drill up Drill down Question # 3 of 10 ( Start time: 03:38:07 PM )   Total Marks: 1 Which of the denormalization technique squeezes master table into detail? Select correct option: Pre-joining Horizontal splitting Vertical splitting Adding redundant column Question # 4 of 10 ( Start time: 03:38:28 PM )   Total Marks: 1 The trade-offs of denormalization is/are: Select correct option: Storage Performance Ease-of-use All of the given options Question # 5 of 10 ( Start time: 03:38:46 PM )   Total Marks: 1 ________is usually deployed when expressions can be used to group data together in...