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 / santhi perumal
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k;
char a[100];
printf("Enter the String\n");
gets(a);
printf("The Given String is %s \n",a);
for(i=0; a[i] != '\0';i++)
{
if(a[i] == ' ')
{
for(k=i+1;a[k] != '\0';k++)
{
if(a[i+1] == ' ')
{
for(j=i+1;a[j] != '\0';j++)
{
a[j] = a[j+1];
}
a[j] ='\0';
}
}
}
}
printf("The Resulted String is %s\n ",a);
}
| Is This Answer Correct ? | 3 Yes | 4 No |
Post New Answer View All Answers
What is the basic structure of c?
What is a constant and types of constants in c?
#include
In which language linux is written?
Explain how are portions of a program disabled in demo versions?
Is main a keyword in c?
What is cohesion and coupling in c?
What is the return type of sizeof?
Is boolean a datatype in c?
What is difference between array and structure in c?
how can I convert a string to a number?
Differentiate between full, complete & perfect binary trees.
What are the different categories of functions in c?
a value that does not change during program execution a) variabe b) argument c) parameter d) none
Why do we use & in c?