ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Reverse a string word by word??
 Question Submitted By :: Varu
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Reverse a string word by word??
Answer
# 1
#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 ?    3 Yes 7 No
Vignesh1988i
 
  Re: Reverse a string word by word??
Answer
# 2
#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 ?    8 Yes 3 No
Vishnu948923
 
 
 
  Re: Reverse a string word by word??
Answer
# 3
strrev(str1,str2);
 
Is This Answer Correct ?    0 Yes 7 No
Guest
 
  Re: Reverse a string word by word??
Answer
# 4
#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 ?    1 Yes 1 No
Rohit_Kamlakar
 
  Re: Reverse a string word by word??
Answer
# 5
#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 2 No
Vamsi
 
  Re: Reverse a string word by word??
Answer
# 6
#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 0 No
Dally
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
The C language terminator is a.semicolon b.colon c.period d.exclamation mark TCS3
how many error occurs in C language ? Wipro11
Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times the loop is executed ? Mascot3
You are given a string which contains some special characters. You also have set of special characters. You are given other string (call it as pattern string). Your job is to write a program to replace each special characters in given string by pattern string. You are not allowed to create new resulting string. You need to allocate some new memory to given existing string but constraint is you can only allocate memory one time. Allocate memory exactly what you need not more not less. Microsoft2
int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation. Global-Edge11
Write the program for displaying the ten most frequent words in a file such that your program should be efficient in all complexity measures. Google3
What is the purpose of Scanf Print, getchar, putchar, function?  2
what are two categories of clint-server application development ?  1
what is diff b/w huge & far & near pointer?? HCL1
Write a C program that reads a series of strings and prints only those ending in "ed"  2
Is main() function predfined or userdefined?  7
write a program to find the number of even integers and odd integers in a given array in c language Olive-Tech2
what is the difference between #include<stdio.h> and #include "stdio.h" ?  2
Given an unsigned integer, find if the number is power of 2?  3
Can I pass constant values to functions which accept structure arguments?  2
In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT IBM1
program to find the ASCII value of a number  5
difference between my-strcpy and strcpy ? Geometric-Software3
24.what is a void pointer? 25.why arithmetic operation can’t be performed on a void pointer? 26.differentiate between const char *a; char *const a; and char const *a; 27.compare array with pointer? 28.what is a NULL pointer? 29.what does ‘segmentation violation’ mean? 30.what does ‘Bus Error’ mean? 31.Define function pointers? 32.How do you initialize function pointers? Give an example? 33.where can function pointers be used?  1
We can draw a box in cprogram by using only one printf();& without using graphic.h header file? NIIT3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com