Write a program that accepts a string where multiple spaces
are given in between the words. Print the string ignoring
the multiple spaces.
Example:
Input: “ We Are Student “
Output: "We Are Student"
Answer Posted / vadivel t
#include<stdio.h>
main()
{
char *p, *q, *q1;
p = (char *)malloc(200);
q = (char *)malloc(200);
q1 = q;
printf("ENTER THE SENTENCE: \n");
p = gets(p);
while(*p != '\0')
{
if(*p != ' ' || *(q -1) != ' ')
{
*q++ = *p++;
}
else
p++;
}
*q = '\0';
printf("%s", q1);
getch();
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are the advantages of external class?
Can main () be called recursively?
Write a program to find the biggest number of three numbers in c?
what will be maximum number of comparisons when number of elements are given?
Is python a c language?
What are disadvantages of C language.
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
#include
What is the difference between procedural and declarative language?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
What is null character in c?
What are global variables and how do you declare them?
What does 3 periods mean in texting?
Explain what header files do I need in order to define the standard library functions I use?
What is cohesion and coupling in c?