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.
Following method has used in printing string line by line.
- Take one input string from user.
- Run the iteration(for loop) till the last of input string.
- Inside for loop(you can use any loop) use \n command.
- \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.
Reviewed by Deepak kumar soni
on
December 24, 2018
Rating:
No comments: