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                      
tip   SiteMap shows list of All Categories in this site.
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
Given an array of characters, how would you reverse it? How 
would you reverse it without using indexing in the array?
 Question Submitted By :: San
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Given an array of characters, how would you reverse it? How would you reverse it without using indexing in the array?
Answer
# 1
#include <stdio.h>

void reverse ( char* cp_str )
{
	char* cp_rev_ptr = NULL;
	cp_rev_ptr = cp_str;
	while ( ( cp_rev_ptr ) && ( *cp_rev_ptr != '\0' ) ) 
cp_rev_ptr++;
	cp_rev_ptr--;

	while ( cp_str < cp_rev_ptr ) {
		*cp_str ^= *cp_rev_ptr ^= *cp_str ^= 
*cp_rev_ptr;
		cp_str++;
		cp_rev_ptr--;
	}
}

int main ( int argc, char* argv [] )
{
	char array [] = {"dlroW olleH"};

	printf ("\nBefore :%s", array );
	reverse ( array );
	printf ("\nAfter :%s", array );

	return ( 0 );
}

Output
======
Before :dlroW olleH
After :Hello World
 
Is This Answer Correct ?    4 Yes 1 No
Abdur Rab
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
#define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs? Ramco4
for(i=1;i>0;i++); printf("i=%d",i); what will be the answer????  6
O,T,T,F,F,S,S,E,N,?,?,?,T,F,F,S,S,E,N ADP9
why i join syntel? Syntel12
pick out the odd one out of the following a.malloc() b.calloc() c.free() d.realloc() TCS1
what is call by value and call by reference  2
int a=1,b=2,c=3; printf("%d,%d",a,b,c); What is the output? Verifone14
what is the use of getch() function in C program.. difference b/w getch() and getche()?? Wipro12
Write a program to compute the following 1!+2!+...n!  3
a C prog to swap 2 no.s without using variables just an array? TCS4
which one of follwoing will read a character from keyboard and store in c a)c=getc() b)c=getchar() c)c=getchar(stdin) d)getc(&c) e)none  5
YBJBU6  1
what is data structure  4
nnnn  1
wats SIZE_T meant for?  1
what is self refrential structure HCL2
what's the return value of malloc()  8
Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)  2
why division operator not work in case of float constant?  1
Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse to it. eg:123 output:123321 (or) 12321  2
 
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