Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why I put \n in this

+8 votes
asked Jul 5, 2022 by Jason (200 points)
#include <stdio.h>
#include <string.h>

int main()
{
    
    int T, R;
    char a[20];
    
    scanf("%d", &T);
    
    
    
    for(int i=0;i<T ; i++){
         scanf("%d %s", &R, a );
         
         for(int u=0; u< strlen(a); u++ ){
         for(int j=0; j<R; j++)
         printf("%c", a[u]);
        
         }
         
         printf("\n");
             
       
    }
    
    
    
    
    
    return 0;
}

4 Answers

+1 vote
answered Jul 5, 2022 by Peter Minarik (84,720 points)

With printf("\n"); in your code, every time you'll read the next R and a, you will do it on a new (empty) line.

0 votes
answered Jul 6, 2022 by AADI JAIN (350 points)
helps to get into a new line also useful in better understanding of the code by writing and printing it neatly so user can clarify when a new line or set of code starts
+3 votes
answered Jul 11, 2022 by Gayathri (200 points)
\n is used to get new line or next line . It should be used in printf statement with in double quotations. EX: printf("%d\n%d",1,2) . Output : In first line 1 and in second line 2 will be printed
0 votes
answered Jul 29, 2022 by NirjalLOL (540 points)

helps to get into a new line also useful in better understanding of the code by writing and printing

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...