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 “ Note: one .=1 Space
Output: "We Are Student"

Answer Posted / jyotsna

/* Assume ' ' at the place of '.' */

#include<conio.h>
#include<stdio.h>
void main()
{
char *s="Hello...this...is...jyotsna";
int i=0;
clrscr();

while(*s!='\0')
{
if(*s!='.')
{
printf("%c",*s);
i=0;
s++;
}
else
{
while(*s=='.')
s++;

printf(".");
}
}
getch();
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I open a file so that other programs can update it at the same time?

648


praagnovation

1766


Who developed c language and when?

569


What does %p mean?

579


How can I find out how much free space is available on disk?

620






What happens if you free a pointer twice?

594


Explain modulus operator. What are the restrictions of a modulus operator?

591


Explain how can I convert a string to a number?

632


Is fortran still used today?

592


What is a program?

647


Write a program to swap two numbers without using third variable?

807


Explain how can you tell whether a program was compiled using c versus c++?

567


What does %d do?

705


Explain what is the advantage of a random access file?

650


What does it mean when the linker says that _end is undefined?

621