Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Reverse a string word by word??

Answers were Sorted based on User's Feedback



Reverse a string word by word??..

Answer / vishnu948923

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void main()
{
int n,i,j=0;
char str[100];
char str1[100];
clrscr();
puts("Enter string:");
gets(str);
n=strlen(str);
for(i=n-1;i>=0;i--)
{
if(str[i]==' ')
{
str1[j]='\0';
strrev(str1);
printf("%s ",str1);
j=0;
}
else
{
str1[j++]=str[i];

}
}
if(i==-1)
{
str1[j]='\0';
strrev(str1);

printf("%s ",str1);
}
getch();
}

//strtoke
//isvowel

Is This Answer Correct ?    24 Yes 10 No

Reverse a string word by word??..

Answer / anand

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char a[]="i am anand";

int x,len,y,z;
len=strlen(a);
z=len-1;
for(x=len-1;x>=0;x--)
{
if(a[x]==' '||x==0)
{
for(y=x;y<=z;y++)
{
printf("%c",a[y]);
}
z=x;
}
}
getch();

}

Is This Answer Correct ?    4 Yes 1 No

Reverse a string word by word??..

Answer / atul kumar rai

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char str[100],temp1;
int i,j,len,temp;
printf("Enter any string : ");
gets(str);
len=strlen(str);
for(i=0,j=len-1;i<j;i++,j--)
{
temp1=str[i];
str[i]=str[j];
str[j]=temp1;
}
for(i=0; str[i]!=NULL; i++)
{
if(str[i+1]==' ' || str[i+1]==NULL)
{
for(temp=i; temp>=0 && str[temp]!=' '; temp--)
printf("%c",str[temp]);
printf(" ");
}
}
getch();
return 0;
}

Is This Answer Correct ?    1 Yes 0 No

Reverse a string word by word??..

Answer / santhosh

This Might Help You ...

http://user-interfaze.blogspot.com/2012/01/c-program-to-reverse-string-word-by.html

Is This Answer Correct ?    0 Yes 0 No

Reverse a string word by word??..

Answer / rohit_kamlakar

#include<iostream.h>
#include<string.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int length,i,j;
char string[500];clrscr();
printf("Enter the string=");
gets(string);
length=strlen(string); int y=length,z=0;
for(i=length-1;i>=0;i--)
{
if(int(string[i])==32)
{ printf(" ");
for(j=i+1;j<length;j++)
{
printf("%c",string[j]);
z++;
}
length=y-z;
}

if(i==0)
{ j=i; printf(" ");
while(int(string[j])!=32)
{
printf("%c",string[j]);

j++;
}
}

}
getch();
}

Is This Answer Correct ?    3 Yes 4 No

Reverse a string word by word??..

Answer / vamsi

#include<stdio.h>
#include<conio.h>
void main()
{
char a[40],temp;
int count=0;
printf("enter the string :");
gets(a);
for(int i=40;a[i]!=a[1];i--)
printf (a[i]);
printf (a[1]);
}

Is This Answer Correct ?    1 Yes 9 No

Reverse a string word by word??..

Answer / dally

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

int main()
{
char array1[] = "STRING FOR TESTNG";
char array2[20],i=0;
int count;
count = strlen(array);
for(count;count>1;count--)
{
array2[i]= array1[count];
i++;
}
printf("%s\n",array2);

}

Is This Answer Correct ?    0 Yes 8 No

Reverse a string word by word??..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
char a[40],temp;
int count=0;
printf("enter the string :");
gets(a);
for(int i=0;a[i]!='\0';i++)
count++;
for(i=0;a[i]!='\0';i++)
{
if(count>i)
{
temp=a[i];
a[i]=a[count-1];
a[count-1]=temp;
count--;
}
else
break;
}
printf("the reversed ones is : ");
puts(a);
getch();
}

thank u

Is This Answer Correct ?    9 Yes 21 No

Reverse a string word by word??..

Answer / guest

strrev(str1,str2);

Is This Answer Correct ?    1 Yes 17 No

Post New Answer

More C Interview Questions

program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.

3 Answers  


how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 012345 01234 0123 012 01 0

4 Answers   Wipro,


What is p in text message?

0 Answers  


What is the explanation for modular programming?

0 Answers  


Find greatest number out of 10 number without using loop.

5 Answers   TCS,


Explain how do you use a pointer to a function?

0 Answers  


what is c++ programming?

3 Answers   TCS,


What is void c?

0 Answers  


What are pointers? Why are they used?

0 Answers  


What is pre-emptive data structure and explain it with example?

0 Answers  


main() { int age; float ht; printf("Enter height and age"); scanf("%d%d",&height,&age); if((age<=20)&&(ht>=5)) {printf("She loves you");} else {printf("She loves you");} }

2 Answers  


Explain what does a function declared as pascal do differently?

0 Answers  


Categories