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

Answers were Sorted based on User's Feedback



write an algorithm to get a sentence and reverse it in the following format: input : I am here op..

Answer / anshu ranjan

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void main()
{char *s,*t;
int i=0,j=0;
s=(char *)malloc (1000*sizeof(char));
t=(char *)malloc (50*sizeof(char));
gets(s);
i=strlen(s)-1;
while(i>=-1)
{
if(s[i]!=' ' && i>=0)
t[j++]=s[i--];
else {if(t[j-1]>=97 && t[j-1]<=122)
t[j-1]-=32;
i--;
t[j]=0;
//printf("%s ",t);
strrev(t);
printf("%s ",t);
j=0;
}
}
}

Is This Answer Correct ?    10 Yes 0 No

write an algorithm to get a sentence and reverse it in the following format: input : I am here op..

Answer / debasis patnaik

ALGO:1.TAKE A STRING STR1
2.REVERSE IT BY STRREV(STR1)
3.CONCANICATE WITH SPACEBY STRCAT(" ",STR1)AND ASSIGN TO STR2
4.IF(STR2[I]==" ")
{
(ISUPPER(STR2[I+1])))
PRINT(STR(2)
5.END

Is This Answer Correct ?    3 Yes 1 No

write an algorithm to get a sentence and reverse it in the following format: input : I am here op..

Answer / 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

More C Interview Questions

What is the difference between printf and scanf )?

0 Answers  


how to copy a string without using c function

5 Answers  


Explain how many levels deep can include files be nested?

0 Answers  


Write a program to exchange two variaables without temp

9 Answers   Geometric Software,


What is the concatenation operator?

0 Answers  






What is sizeof in c?

0 Answers  


What is character constants?

0 Answers  


There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side?

8 Answers   Google,


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

0 Answers   TCS,


Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

0 Answers  


How pointer is different from array?

0 Answers  


Is c procedural or functional?

0 Answers  


Categories