Programme to print string line by line.

                C  Programme to print string line by line

Hello,readers this is the code to print name line by line in c language.
string is simply array of character.This blog will introduce you to the
concept of how to print string line by line.

 


   
https://programminghub1999.blogspot.com/2018/12/programme-to-print-name-line-by-line_92.html




                           Following method has used in printing string line by line.

  1. Take one input string from user.
  2. Run the iteration(for loop) till the last of input string.
  3. Inside for loop(you can use any loop) use \n command.
  4. \n command use in to display somethin in next line.

                            Print string line by line




#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
       clrscr();
      char ch[30];
      int i;
      printf("Enter string\n");
      gets(ch);
      for(i=0;ch[i]!='\0';i++)
      {
          printf("%c \n",ch[i]);
      }
     getch();
}



output will be like this:
Enter string
Computer
C
o
m
p
u
t
e
r

If you like this please comment .
And follow my profile for more and also share this code to your friends.



                                       
Programme to print string line by line. Programme to print string line by line. Reviewed by Deepak kumar soni on December 24, 2018 Rating: 5

No comments:

Powered by Blogger.