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

A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

668


Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"

1582


How can I avoid the abort, retry, fail messages?

657


What is null pointer constant?

594


When should the volatile modifier be used?

687






Should a function contain a return statement if it does not return a value?

597


How are pointers declared in c?

596


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2334


Calculate 1*2*3*____*n using recursive function??

1517


Write a program to find factorial of a number using recursive function.

646


Explain what is the use of a semicolon (;) at the end of every program statement?

733


What are the scope of static variables?

601


difference between Low, Middle, High Level languages in c ?

1634


What does s c mean on snapchat?

586


Write a C program in Fibonacci series.

635