Showing posts with label strings. Show all posts
Showing posts with label strings. Show all posts
Monday, February 16, 2015
C Program to reverse all the strings stored in an array
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
char a[3][50];
int i,j,k,len;
cout<<"Enter 3 strings:
";
for(i=0;i<3;i++)
{
gets(a[i]);
}
cout<<"
The list of orignal strings:
" ;
for(i=0;i<3;i++)
{
cout<<a[i]<<"
";
}
cout<<"
The list of changed string:
";
for(i=0;i<3;i++)
{
len=strlen(a[i]);
for(j=0,k=len-1;k>=0;j++,k--)
{
cout<<a[i][k];
}
cout<<"
";
}
getch();
}
Subscribe to:
Posts (Atom)