Write a C program that will enter a line of text, store in an array and then display backwards. The length of the line should be undefined, (being terminated by ENTER key), but less than 80 characters.
#include <stdio.h>
#include <conio.h>
void backward ( char str[] )
{
int i;
for ( i = 0; str[i] != '\0'; i++ );
printf("\n\n\t The text in backward direction is..:");
for ( i = i -1; i >= 0; i-- )
{
printf("%c",str[i] );
}
}
void main ( )
{
char str[80];
clrscr ( );
printf("\n\n\n\t Enter the line of text..:"); gets( str );
backward ( str );
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
void backward ( char str[] )
{
int i;
for ( i = 0; str[i] != '\0'; i++ );
printf("\n\n\t The text in backward direction is..:");
for ( i = i -1; i >= 0; i-- )
{
printf("%c",str[i] );
}
}
void main ( )
{
char str[80];
clrscr ( );
printf("\n\n\n\t Enter the line of text..:"); gets( str );
backward ( str );
getch ( );
}
Click here to contact us
No comments:
Post a Comment