How to handle printf in C language

Asked

Viewed 101 times

1

Hello!

How do I put something after the variable in a printf. Ex:

printf("Digite um valor para a posição: [%d", l); printf(" ,%d", c); printf(" ]");

I am using the example above, but I was wondering if it is possible to do something similar to pseudocode: Ex:

printf("Digite um valor para a posição: [%d", l, ",", c, " ]");

The end result would be something like:

Type a value for position [ x, y]:

2 answers

2


int main() 
{  
    int x=5;  
    int y=3;  
    printf("Digite um valor para a posição [%d, %d]", x, y);  
    return 0;  
}

As it turned out:

Enter a value for the position [5, 3]

0

#include <stdio.h>

int main(void)
{
    int x, y;

    printf("Digite dois valores para definir a posição [x, y]\n");
    scanf("%d %d", &x, &y);
    printf("Posição escolhida [%d , %d].", x , y);

  return 0;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.