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...

write an algorithm to get a sentence and reverse it in the
following format:
input : I am here
opuput: Here Am I
note: first letter of every word is capiatlised

Answer Posted / vignesh1988i

here using pointers we can easily do the above..........


#include<stdio.h>
#include<conio.h>
#include<alloc.h>
void main()
{
char a[50],*ptr,*pointer;
int n,i,j,k;
printf("enter the string:");
gets(a);
for(i=0;a[i]!='\0';i++)
n++;
pointer=(char*)malloc((n+1)sizeof('2'));
j=0;
for(i=0;a[i]!='\0';)
{
if(a[i]==' ')
{
*(pointer+(n-j-1))=a[i];
i++; j++;
}
else
{
ptr=&a[i];
for(k=0;a[i+1]!=' '&&a[i+1]!='\0';k++)
i++;
for(k=0;k<((&a[i]-ptr)+1);k++)
{
*(pointer+(n-j-1))=*(ptr+(&a[i]-ptr)-k);
j++;
}
}
i++;
}
*(pointer+(n+1))='\0';
for(i=0;i<n;i++)
printf("%c",*(pointer+i));
getch();
}



thank u

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the need of structure in c?

1048


In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

1796


Simplify the program segment if X = B then C ← true else C ← false

2958


What are different types of operators?

990


Is Exception handling possible in c language?

1990


What the different types of arrays in c?

1020


What is double pointer in c?

983


Why clrscr is used in c?

952


What is a stream?

1078


PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE

1948


The __________ attribute is used to announce variables based on definitions of columns in a table?

1128


Create a simple code fragment that will swap the values of two variables num1 and num2.

1234


Difference between goto, long jmp() and setjmp()?

1121


Where are local variables stored in c?

981


Is register a keyword in c?

993