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
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
int far *near * p; means
In c language can we compile a program without main() function?
1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
What are valid operations on pointers?
c program to compute AREA under integral
What is the use of structure padding in c?
What is hashing in c?
Is that possible to store 32768 in an int data type variable?
What are the 5 types of inheritance in c ++?
What is a example of a variable?
Explain the concept and use of type void.
What is the advantage of using #define to declare a constant?
write a program to concatenation the string using switch case?