Q. Write a C program to print the string vertically only words not all characters.
For example:
string: You are genius to learn C language
result:
You
are
genius
to
learn
C
Language
Ans.
/*c program to print string vertically only words not characters*/
#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++)
{
if(str[i]==' ')
printf("\n");
else
printf("%c",str[i]);
}
getch();
return 0;
}
/***********Output***********/
For example:
string: You are genius to learn C language
result:
You
are
genius
to
learn
C
Language
Ans.
/*c program to print string vertically only words not characters*/
#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++)
{
if(str[i]==' ')
printf("\n");
else
printf("%c",str[i]);
}
getch();
return 0;
}
/***********Output***********/
Screen shot for print string vertical only words not characters C program |
How about in reversed? Pls Help!
ReplyDelete@Edwin Moises Adigue,
DeleteDescribe your questions. All string related C program at:
http://cprogrammingcodes.blogspot.in/2012/07/reverse-all-string.html