Docsity

Code Analysis-Data Stucture Programming-Quiz, Exercises of Data Structures and Algorithms

Toggle sidebar
bg1
CS2143-2144 Data Structures Spring 2012
Quiz # 1 (14 February 2012)
Time 10 Minutes
Max. Marks 10
Name: Reg. No: ___
What is being done in the following code? Explain line by line and tell what will be the
final output. The line number are printed just for reference, these are not the part of the
program code.
1. #include <iostream>
2. using namespace std;
3. int main ()
4. {
5. int firstvalue, secondvalue;
6. int * mypointer;
7. firstvalue = 100;
8. secondvalue = 300;
9. mypointer = &firstvalue;
10. *mypointer = 30;
11. mypointer = &secondvalue;
12. *mypointer = 40;
13. cout << "firstvalue is " << firstvalue << endl;
14. cout << "secondvalue is " << secondvalue << endl;
15. return 0;
16. }
Docsity.com

Partial preview of the text

Download Code Analysis-Data Stucture Programming-Quiz and more Exercises Data Structures and Algorithms in PDF only on Docsity!

CS2143-2144 Data Structures Spring 2012

Quiz # 1 (14 February 2012)

Time 10 Minutes

Max. Marks 10

Name: Reg. No: ___

What is being done in the following code? Explain line by line and tell what will be the

final output. The line number are printed just for reference, these are not the part of the

program code.

  1. #include
  2. using namespace std;
  3. int main ()
  4. {
  5. int firstvalue, secondvalue;
  6. int * mypointer;
  7. firstvalue = 100;
  8. secondvalue = 300;
  9. mypointer = &firstvalue;
  10. *mypointer = 30;
  11. mypointer = &secondvalue;
  12. *mypointer = 40;
  13. cout << "firstvalue is " << firstvalue << endl;
  14. cout << "secondvalue is " << secondvalue << endl;
  15. return 0;
  16. }

Docsity.com