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

Why c is a mother language?

986


Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1125


What is a pragma?

1091


Does c have enums?

1048


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1035


What is the difference between the expression “++a” and “a++”?

1188


What is a struct c#?

1013


How do you print only part of a string?

980


Why & is used in c?

1128


Write a program to swap two numbers without using third variable in c?

1085


What is a lvalue

1048


Here is a good puzzle: how do you write a program which produces its own source code as output?

1057


Explain how does flowchart help in writing a program?

1076


What is the meaning of && in c?

976


"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above

992