# Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 171 - 173 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

## Question 171

C & C Plus Plus
Edit

### Describe in Detail

Essay▾

What is a scope resolution operator?

### Explanation

• The scope resolution operator “::” is used to qualify hidden names.
• We can use the unary scope operator if a namespace scope or global scope name is hidden by an explicit declaration of the same name in a block or class.

Example:

1. `int count=0;`
2. `int main(void)`
3. `{`
4. `    int count=0;`
5. `    :: count =1;`
6. `    count =2;`
7. `    return 0;`
8. `}`

## Question 172

C & C Plus Plus
Edit

### Describe in Detail

Essay▾

What is the output of the following program?

1. `main ()`
2. `{`
3. `    int i=10,j=20; j =i, j?(i,j)?i:j:j; printf("%d %d",i,j);`
4. `}`

### Explanation

In the program

 int i = 10, j = 20; Given the integer variable i = 10 and j = 20 j = i, j? (i, j) ? i: j: j; The ternary operator (? :) is equivalent for if-then-else statement.So, the question can be written as:if (i, j){if (i, j) j = i;else j = j;} else j = j; printf ( “% d % d” , i, j) ; Printf prints the value of i and j

## Question 173

C & C Plus Plus
Edit

### Describe in Detail

Essay▾

What is the output of the program given below

1. `main ()`
2. `{`
3. `    signed char i =0;`
4. `    for (; i>= 0; i ++ );`
5. `    printf ( “%d” i);`
6. `}`

### Explanation

• In the program define the signed char
• Signed char represents integers from -128 to 127.
 signed char i = 0; Define the signed character variable i = 0 for (; i >= 0; i ++) ; The semicolon at the end of the for loop.The initial value of the i is set 0.The inner loop executes to increment the value from 0 to 127 (the positive range of char) and then it rotates to the negative value of -128.The condition in the for loop fails and so comes out of the for loop. printf ( “% d” i) ; It prints the current value of I that is -128.

Developed by: