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 / pramod

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
int i,j,k,len;
char a[100];

printf("Enter the String\n");
gets(a);
printf("The Given String is %s \n",a);
len=strlen(a);
for(i=0; i<len;i++)
{
if(a[i] == ' ')
{
if(a[i+1]==' ')
{
int j=i+1;
while(a[j]==' ')
{
j++;
len--;
}
for(k=i+1;a[j]!=NULL;)
{
a[k++]=a[j++];
}
}
}
}
a[i]='\0';
printf("The Resulted String is %s\n ",a);

}

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a #include preprocessor?

1096


What does %p mean c?

1024


Explain built-in function?

1099


Explain how can I remove the trailing spaces from a string?

1010


Explain what math functions are available for integers? For floating point?

1075


which is conditional construct a) if statement b) switch statement c) while/for d) goto

1176


What does 3 mean in texting?

1047


Differentiate between functions getch() and getche().

1000


Difference between pass by reference and pass by value?

1107


Can you return null in c?

1107


WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

1813


How can you determine the maximum value that a numeric variable can hold?

1176


Write a Program to find whether the given number or string is palindrome.

1242


How to set file pointer to beginning c?

1164


What is the mean of function?

1079