Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the basic structure of c?

1086


What is a constant and types of constants in c?

1140


#include { printf("Hello"); } how compile time affects when we add additional header file .

1898


In which language linux is written?

1231


Explain how are portions of a program disabled in demo versions?

1124


Is main a keyword in c?

1138


What is cohesion and coupling in c?

1036


What is the return type of sizeof?

1067


Is boolean a datatype in c?

1071


What is difference between array and structure in c?

1197


how can I convert a string to a number?

1085


Differentiate between full, complete & perfect binary trees.

1112


What are the different categories of functions in c?

1138


a value that does not change during program execution a) variabe b) argument c) parameter d) none

1239


Why do we use & in c?

1007