Just replace the ' n’s of the first and second printf with ' t’s, in this way it will not break the line, which in case is ' n', and will still give a tab, in case t, (equivalent to four spaces).
#include <stdio.h>
int main ()
{
int i=0, num=0;
printf ("Digite um n£mero: ");
scanf ("%d",&num);
printf ("\n");
while ( i <= 9 )
{
i++;
printf ("%d + %d = %d\t", i, num, num+i);
printf ("%d - %d = %d\t", i, num, i-num);
printf ("%d X %d = %d\n", i, num, num*i);
}
return 0;
}
In this case the output will be like this:
another way:
#include <stdio.h>
#include <locale.h>
int main ()
{
int i = 0, num = 0;
setlocale(LC_ALL, "");
printf ("Digite um número: ");
scanf (" %d", &num);
printf ("\nAdição:\n");
for ( i = 0; i <= 9; i++ )
printf ("%d + %d = %d\n", i, num, num+i);
printf ("\nSubtração:\n");
for ( i = 0; i <= 9; i++ )
printf ("%d - %d = %d\n", i, num, i-num);
printf ("\nMultiplicação\n");
for ( i = 0; i <= 9; i++ )
printf ("%d X %d = %d\n", i, num, num*i);
return 0;
}
This way the output will be sequential, I added the locale library. h to use accent, the command setlocale(LC_ALL, "");
is the command that allows BR accents to be used, the image of this output is this:
how to organize?
– M. Bertolazo
When I run it gets all messy like 1+1, 1-1, 1x1, 2+1, 2+1, 2-1, 2x1 ... and so on to 10.
– Gustavo Carvalho