PuzzlersWorld.com

  • Hacker Puzzle
  • Interview Puzzles
  • Number Puzzles
  • Maths Puzzles

Subjective Question set C/C++ – Part 1

(1 votes, average: 3.00 out of 5)

January 3, 2013 by puzzler Leave a Comment

Q1) int a[10[15];
char b[10[15];
What will be the location of a[3][4], if base location a[0][0] is ox1000?
What will be the location b[3][4], if base location b[0][0] is ox2000?

See AnswerHide Answer
(a) ox10C4 (b) ox2031
Let me know if you need the solution in detail.
Q2) How can the unary operator ++ be overloaded in C++ for postfix operation ?

See AnswerHide Answer
We need to declare postfix notation with an int inside: A operator++(int); // postfix
Prefix declaration is declared without int in the brackets: A operator++(); // prefix
Example definition of a postfix operator

//Example definition of a postfix operator
A A::operator++(int)
{
    // Create a temporary variable with our current digit
    A temp= A();

    // Use prefix operator to increment this digit
    ++(*this);// apply operator

    // return temporary result
    return temp;       // return saved state
}

Q3)
fun(int a)
{
static int b;
}
what is the storage allocation for both a and b ?
See AnswerHide Answer

a will be stored in stack while b will be stored in the data segment (as it is a static variable, shared across the function calls)

Q4) How can we initialize a const data member in a class?
See AnswerHide Answer

Class sample{
Const int i;
 Public: sample(int j):i(j){   }
};

Q5) Class D: public B2, B1; what is the order of execution of constructors and destructors of classes D, B1 and B2.
See AnswerHide Answer

Constructors: B2 -> B1 -> D
Destructors: D -> B1 -> B2

Q6) Allocate a 2-D array using new such that its elements to be accessed as a[i][j].
See AnswerHide Answer

Int (*p)[MAXCOL] P = new int[MAXROW][MAXCOL]
  • Share on Whatsapp
  • Share on Facebook
  • Share on Twitter
Facebook Comments
Next Puzzle
Find all non duplicate pairs that sum to S

Checkout more Interview Questions Tags: C/C++, Interview, Solved Puzzles

Leave a Comment Cancel reply

Submit your Puzzle

You may also like

  • Spinning Disc Direction Puzzle
  • Dead Pixels solution: Facebook hacker cup 2013 Round 1
  • Objective Questions set C/C++ – Part 3
  • Falling Diamonds Solution: Google codejam 2013 Round 1B
  • Fair and Square Solution: Google codejam 2013 Qual Round
  • Objective Questions set C/C++ – Part 4
  • Balanced Smileys solution: Facebook hacker Cup 2013 Qual Round
  • Find the Min solution: Facebook hacker Cup 2013 Qual Round
  • Sort the array in O(N)
  • Cake Cutting solution: Facebook hacker cup 2013 Round 2

Categories

  • Aive hi Puzzles
  • Akbar and Birbal
  • Alphabetical Puzzles
  • Bollywood Puzzles
  • Google Code jam
  • Hindi Riddles
  • Interview Puzzles
  • Interview Questions
  • Logical Puzzles
  • Malayalam Puzzles
  • Maths Puzzles
  • Miscellaneous
  • Number Puzzles
  • Picture Puzzles
  • Riddles
  • Tamil Puzzles
  • Technical

Social

  • View puzzlersworld’s profile on Twitter
privacy policy

Copyright © 2025 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in

  • Hacker Puzzle
  • Logo Puzzles
  • Optical Illusions
  • WhatsApp Puzzles
  • Picture Puzzles
  • Riddles
    ▼
    • Hindi Riddles
  • Bollywood Puzzles
  • Alphabetical Puzzles
  • Aive hi Puzzles
  • Interview Puzzles
  • Logical Puzzles
  • Interview Questions
    ▲
    • Data Structures
    • Binary Tree
    • Algorithms
    • Recursion Questions
    • Amazon Interview Questions
    • Snapdeal Interview Questions
    • Google Code jam
  • Technical
  • Akbar and Birbal
  • Number Puzzles
  • Maths Puzzles
  • Miscellaneous