Q. Write a C program to read a string from user and display it in vertical.
For example: Entered String is : Sample String
After programmed, resulted string is :
S
a
m
p
l
e
S
t
r
i
n
g
Ans.
/*c program for display a string in vertical*/
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
char str[30];
printf("Enter any string : ");
gets(str);
for(i=0; str[i]!='\0'; i++)
printf("%c\n",str[i]);
getch();
return 0;
}
/***************Output******************/
Related programs:
For example: Entered String is : Sample String
After programmed, resulted string is :
S
a
m
p
l
e
S
t
r
i
n
g
Ans.
/*c program for display a string in vertical*/
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
char str[30];
printf("Enter any string : ");
gets(str);
for(i=0; str[i]!='\0'; i++)
printf("%c\n",str[i]);
getch();
return 0;
}
/***************Output******************/
Screen shot for display string vertical C program |
Related programs:
Comments
Post a Comment