Tuesday, January 2, 2007

Anothr good Problem

wite a program to reverse the sentence ex:- this is a man! and you should print the output as "man a is this" ....dont use any library functions.

Here is my simple logic... i really don kno if it works (hehehhhe )

#include
#include

main()
{
char *q = "this is a man";
char *a,*b,c[10][25];
int l = 0,i,j = 0,k;
clrscr();

a = q;
b = q;

while(*a != '\0')
{
b++;
a++;
if(*b == ' ')
{
a++;
*b = '\0';
b++;
l++;
}
}
a = q;
for(i = 0;i <= e;i++)
{
while(c[j++] = *a++);
j = 0;
}
for(k = l;k >= 0;k--)
printf("%s ",c[k]);
getch();
return(0);
}

i think this is the sol'n , but if i m wrong please tell me .

No comments:

Thats mee ...

Thats mee ...

About Me

Delhi, Delhi, India
I am an Electrical Engineering student of Indian Institute of Technology, Delhi. I am currently in 5th year of my Dual Degree course. By the end of this course I will proudly be called Masters in Information and Communication Technology. I have hard core programming interest and good at Networking Fundamentals. Enjoy surfing around Linux journals.