---
title: "What will be the output of following program code?"  
description: "What will be the output of following program code?"  
author: "Mukul Goenka"  
published: 2021-11-10  
canonical: https://www.mindstick.com/interview/33814/what-will-be-the-output-of-following-program-code  
category: "java"  
tags: ["programming language"]  
reading_time: 1 minute  

---

# What will be the output of following program code?

What will be the output of following program code?

```
#include <stdio.h> int main (void) {char p; char buf [10] = {1, 2, 3, 4, 5, 6, 9, 8}; p = (buf + 1) [5]; printf ("%d", p); return 0;} 
```

## Answers

### Answer by Ravi Vishwakarma

```
#include <stdio.h>int main(){    char p;     char buf [10] = {1, 2, 3, 4, 5, 6, 9, 8};     p = (buf + 1) [5];     printf ('P : %d', p);    return 0;}
```

## the output is

```
P : 9
```

Because (buf + 1) jump the one index right. show indexing start from value 2.

### Answer by Mukul Goenka

What will be the output of following program code?

```
#include <stdio.h> int main (void) {char p; char buf [10] = {1, 2, 3, 4, 5, 6, 9, 8}; p = (buf + 1) [5]; printf ("%d", p); return 0;} 
```


---

Original Source: https://www.mindstick.com/interview/33814/what-will-be-the-output-of-following-program-code

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
