8.05.2012

String vertical using pointer

Q. Write a C program to accept a string and print its in vertical order using pointer.


Ans.


/*c program to print string vertically using pointer*/
#include<stdio.h>
#include<conio.h>
int main()
{
 char str[30];
 char *p;
 printf("Enter any string: ");
 gets(str);
 printf("String in vertical order as:\n\n");
 for(p=str; *p!='\0'; p++)
   printf("%8c\n",*p);
 getch();
 return 0;
}


/************Output************/


Output of display string vertically using pointer C program
Screen shot for print string vertically
using pointer C program

No comments:

Post a Comment