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"



Write a program that accepts a string where multiple spaces are given in between the words. Print ..

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

More C Interview Questions

How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

0 Answers  


What are the types of data types and explain?

0 Answers  


what is Structural oriented language? give some example of this language.....?

1 Answers  


What are the advantages of using linked list for tree construction?

0 Answers  


a.One Cannot Take the address of a Bit Field b.bit fields cannot be arrayed c.Bit-Fields are machine Dependant d.Bit-fields cannot be declared as static Which of the Following Statements are true w.r.t Bit-Fields A)a,b&c B)Only a & b C)Only c D)All

3 Answers   Accenture, Digg.com,


what is memory leak?

3 Answers  


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

0 Answers  


What is the difference between class and object in c?

0 Answers  


What does *p++ do?

0 Answers  


#include<stdio.h> main() { int a[3]; int *I; a[0]=100;a[1]=200;a[2]=300; I=a; Printf(“%d\n”, ++*I); Printf(“%d\n”, *++I); Printf(“%d\n”, (*I)--); Printf(“%d\n”, *I); } what is the o/p a. 101,200,200,199 b. 200,201,201,100 c. 101,200,199,199 d. 200,300,200,100

1 Answers  


What are lookup tables in c?

0 Answers  


How to swap 3 numbers without using 4th variable?

5 Answers  


Categories