# Languages-C & C Plus Plus [Accenture Placement]: Sample Questions 5 - 7 of 9

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

## Question 5

C & C Plus Plus
Edit

### Write in Short

1. `Void main ()`
2. `{`
3. `    int const ⚹=5;`
4. `    printf(“%d”++(⚹p));`
5. `}`

### Explanation

• In a program int const ⚹ p = 5; Pointer to constant integer printf ( “% d” ++ (⚹ p) ) ; We tried to change constant integer value
• But constant value can՚t change
• So, the answer is Compiler error: Cannot modify a constant value.

## Question 6

C & C Plus Plus
Edit

### Describe in Detail

Essay▾
1. `Main ()`
2. `{`
3. `    Static int var =5;`
4. `    Printf (“%d” var--);`
5. `    if (var)`
6. `    main ();`
7. `}`

### Explanation

 Static int var = 5 Give static integer value Printf ( “% d” var-) Decrease the integer value if (var) If condition checks whether integer variable is available or not main () Treated like any other ordinary function, which can be called recursively

Given the static integer, it means static storage class is initialized once.

• Static int var = 5
• print 5
• Then v- means decrease the value
• Also check the var variable or not
• If var value is available go to the main () function
• All time same process will be continue till var is not empty
• Printing 5 4 3 2 1

## Question 7

C & C Plus Plus
Edit

### Write in Short

1. `main()`
2. `{`
3. `    char ⚹p;`
4. `    printf (“%d %d” sizeof (⚹p), sizeof (p));`
5. `}`

### Explanation

 char ⚹ p p is the character pointer printf ( “% d % d” sizeof (⚹ p) , sizeof (p) ) ; Sizeof (⚹ p) prints the pointed variable size and size of pointer respectively 1 and 2

So, print 1 2.

Developed by: