Question: What is the use of width in the `printf()` statement? Why is the output 7 in the example below?

### Code

```
int add(int x, int y)
{
    return printf("%*c%*c",  x, '\r',  y, '\r');
}

int main()
{
    printf("Sum = %d", add(3, 4));
    return 0;
}

```

### Output

> 
> Sum = 7
> 
> 
>

Answer: 
If successful [printf](http://en.cppreference.com/w/cpp/io/c/fprintf) returns the number of characters printed. So, your `printf`call in `main` is printing the number of characters printed by the `printf` in the `add` function, because this is what `add` returns.
printf returns the number of characters printed. In this case you are printing 7 characters by specifying x and y as output lengths. If you change the return statement to:

```
return printf("%*c%*c\n",  x, '\r',  y, '\r'); 

```

The output will be 8, since a new line is also printed.