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
a value that does not change during program execution a) variabe b) argument c) parameter d) none
define string ?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
What is typedef?
Tell me what is null pointer in c?
Explain how can you tell whether two strings are the same?
What is meant by keywords in c?
What do you know about the use of bit field?
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
What is string concatenation in c?
What is the right type to use for boolean values in c?
Tell me is null always defined as 0(zero)?
What is the use of volatile?
shorting algorithmS
Why clrscr is used in c?