Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


How to reverse a String without using C functions ?

Answers were Sorted based on User's Feedback



How to reverse a String without using C functions ?..

Answer / yogesh

#include<stdio.h>
int main()
{
char str[80],str1[80];
int i,j;
printf("\n Enter String:");
fgets(str,80,stdin);
for(i=strlen(str)-1,j=0;i>=1;i--)
str1[j++]=str[i];
printf("Reversed String is:%s",str1);
}

Is This Answer Correct ?    17 Yes 14 No

How to reverse a String without using C functions ?..

Answer / dhirendra kumar

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()

{
clrscr();
char a[30],ch[30];
int i,j,count=0,k=0;
printf("enter string in array\n");
gets(a);


for(i=0;a[i]!='\0';i++)
{
count++;
}
printf("length=%d\n",count);
printf("Reverse string===");
for(i=j;i>=0;i--)
{
putchar(a[i]);
}

getch();
}

Is This Answer Correct ?    3 Yes 2 No

How to reverse a String without using C functions ?..

Answer / sakshi pandey

#include<stdio.h>
#include<conio.h>
void main()
{
char str[6],item;
int i,len;
clrscr();
printf("enter a string:\n");
scanf("%s",&str);
len=strlen(len);
for(i=1;i<=len;i++)
{
item=str[i];
str[i]=str[len];
str[len--]=item;
}
printf("reverse string:%s",str);
getch();
}

Is This Answer Correct ?    12 Yes 12 No

How to reverse a String without using C functions ?..

Answer / vinod

char * rev_string (char * str)
{
char temp;
int i , j;
while(str[i]!= '\0')
i++;
for(j = 0 ; j < i ; j++ , i--)
{
temp = str[j];
str[j] = str[i];
str[i] = temp;
}

return str;
}

Is This Answer Correct ?    3 Yes 3 No

How to reverse a String without using C functions ?..

Answer / dhiru

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()

{
clrscr();
char a[30],ch[30];
int i,j,count=0,k=0;
printf("enter string in array\n");
gets(a);

//j=strlen(a);
for(i=0;a[i]!='\0';i++)
{
count++;
}
printf("length=%d\n",count);
printf("Reverse string===");
for(i=count;i>=0;i--)
{
putchar(a[i]);
}

getch();
}

Is This Answer Correct ?    1 Yes 2 No

How to reverse a String without using C functions ?..

Answer / weqweqwe

void mstrreev(char * inStr)
{
if(*inStr!='\0')
{
return;
}
else
{
*/ mstrreev(++inStr);
}
putchar(*(--inStr));
}
void main(int argc, char* argv[])
{

mstrreev("Sushant");
}

Is This Answer Correct ?    0 Yes 3 No

How to reverse a String without using C functions ?..

Answer / abhishek gambhir

int l=0,i;
while(str[l]!='\0')
{
l++;
}
for(i=l-1;i>=0;i--)
{
cout<<str{i];
}

Is This Answer Correct ?    11 Yes 15 No

How to reverse a String without using C functions ?..

Answer / srinivas

#include<stdio.h>

void main()
{
char s[5]="srini";
char *p;
p=(char*)malloc(sizeof(char)*5);
while((*p++=s[--strlen(s)])!='\0');
*p='\0';
printf("%s",p);
}

Is This Answer Correct ?    6 Yes 10 No

How to reverse a String without using C functions ?..

Answer / kalpana

#include<stdio.h>

void reverse( const char * const sPtr );

int main(){
char sentence[ 80 ];

printf( "Enter a line of text:\n" );
gets( sentence );

printf( "\nThe line printed backwards is:\n" );
reverse( sentence );
}

void reverse( const char * const sPtr ){
if( sPtr[ 0 ] == '\0' ){
return;
}
else{
reverse( &sPtr[ 1 ] );

putchar( sPtr[ 0 ] );
}
}

Is This Answer Correct ?    5 Yes 10 No

How to reverse a String without using C functions ?..

Answer / sushamaa

/*The program to reverse the given input string*/

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
char str[20];
int i=0,a,b;
clrscr();

printf("\nEnter the given string:");
scanf("%s",str);

do
{
a=str[i];
i++;
}while(a!=0);

i=i-1;
printf("\nThe reverse string:");

do
{
b=str[i];
printf("%c",b);
i--;
}while(i>=0);

getch();

Is This Answer Correct ?    9 Yes 17 No

Post New Answer



More C Code Interview Questions

union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("\n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); } a. 4, 4, 4 b. 40, 4, 4 c. 1, 100, 1 d. 40 400 4

3 Answers   HCL,


create a C-code that will display the total fare of a passenger of a taxi if the driver press enter,the timer will stop. Every 10 counts is 2 pesos. Initial value is 25.00

0 Answers   Microsoft,


Finding a number which was log of base 2

1 Answers   NetApp,


Is the following code legal? typedef struct a { int x; aType *b; }aType

1 Answers  


write a program to count the number the same (letter/character foreg: 's') in a given sentence.

2 Answers  






What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


Is the following code legal? struct a { int x; struct a *b; }

2 Answers  


main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above

2 Answers   HCL, LG,


#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }

1 Answers  


What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }

1 Answers  


main() { int i=5,j=10; i=i&=j&&10; printf("%d %d",i,j); }

1 Answers  


abcdedcba abc cba ab ba a a

2 Answers  






Categories