I
I
Ilya Dyomin2019-05-08 14:41:49
C++ / C#
Ilya Dyomin, 2019-05-08 14:41:49

C - how to align text in console?

You need to right-align the response in the console.
Prompt, please, variants of the decision.

#include <stdio.h>

int main() 
{
  int height;
  printf ("height: ");
  scanf ("%d", &height);
  for (int i = 1; i <= height; i++) {
    for (int j = 0; j <= i; j++) {
      printf("#");
    }
    printf("\n");
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-05-08
@Alkhipce

No bike
Minimum field width modifiers
Output alignment

https://cpp.com.ru/shildt_spr_po_c/08/0804.html
https://ru.cppreference.com/w/c/io/fprintf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question