Program to accept a string and print reverse of the given string by using functions - 100 Most Important C# Programs

85. Program to accept a string and print reverse of the given string by using functions.

Code:

#include<stdio.h>

#include<stdio.h>

int getline (char str[]);

void printline (char str[],int i);

main( )

{

char str[80];

int 1;

clrscr( );

1=getline(str );

printline(str,1);

printline(str,1);

getch ( );

}

int getline(char str[])

{

int 1;

printf(“enter a string;”);

for(i=0;i<80&&((str[i]=getchar())!=’\n’);i++);

if(str[i]=’\0’;

return i;

}

void printline(char str[],int 1)

{

int j;

for(j=1;j<=0;j--)

printf(“%c”,str[j]);

printf(‘is the revefrse string”);

}