How to removing white spces in c programming only bu using
loops

Answers were Sorted based on User's Feedback



How to removing white spces in c programming only bu using loops..

Answer / ranj

Aravind has done few mistake in printing the no,
the correct format should like this

int main()
{
int i,number;
char str[10];
gets(str);
number=strlen(str);
printf("String without white space\n");
for(i=0;i<number;i++)
{
if(str[i]==' ');
else
printf("%c",str[i]);
}
}

Is This Answer Correct ?    5 Yes 0 No

How to removing white spces in c programming only bu using loops..

Answer / aravind

int main()
{
int i;
char str[10];
gets(str);
for(i=0;i<=number;i++)
{
if(str[i]==' ')
str[i]=0;
}
printf("string without white space is=%s",str);
}

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More C Interview Questions

What is a built-in function in C?

1 Answers  


Multiply an Integer Number by 2 Without Using Multiplication Operator

0 Answers  


wap to print "hello world" without using the main function.

22 Answers   TCS, Wipro,


Compare interpreters and compilers.

0 Answers  


What is meant by keywords in c?

0 Answers  






code snippet for creating a pyramids triangle ex 1 2 2 3 3 3

4 Answers  


There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side?

1 Answers   Hathway,


How will you declare an array of three function pointers where each function receives two ints and returns a float?

0 Answers   TISL,


how memory store byte

4 Answers   Huawei,


Is it possible to pass an entire structure to functions?

0 Answers  


What is the difference between call by value and call by reference in c?

0 Answers  


write a program that prints a pascal triangle based on the user input(like how many stages) in an efficient time and optimized code?

3 Answers   Oracle,


Categories