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

#include<stdio.h>
#include<conio.h>
void main()
{
char str[100],temp;
printf("enter the string :");
gets(str);
for(int i=0,j=0;str[j]!='\0';j++)
{
if(str[j]!=' ')
{
if(str[j+1]==' ')
{
temp=str[j];
str[j]=' ';
str[i]=temp;
i=i+2;
str[i-1]=' ';
}
else if(str[j+1]!=' ')
{
str[i]=str[j];
i++;
}
}
str[i]='\0';
printf("%s",str);
getch();
}

Is This Answer Correct ?    8 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how can I write functions that take a variable number of arguments?

1060


Add Two Numbers Without Using the Addition Operator

804


What is 02d in c?

1061


Is python a c language?

985


Explain that why C is procedural?

1127


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3230


Why is it that not all header files are declared in every C program?

1190


Do pointers take up memory?

1128


What is the use of typedef in structure in c?

956


What is the general form of a C program?

1010


Can 'this' pointer by used in the constructor?

1076


Tell me the use of bit field in c language?

1050


Linked lists -- can you tell me how to check whether a linked list is circular?

1071


largest Of three Number using without if condition?

1575


What is the use of #include in c?

1069