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

+5 votes
asked Jul 5 by Jason (170 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

0 votes
answered Jul 5 by Peter Minarik (55,660 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 by AADI JAIN (340 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
+1 vote
answered Jul 11 by Gayathri (160 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 by NirjalLOL (440 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.
...