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

12. Look at the Code: main() { int a[]={1,2,3},i; for(i=0;i<3;i++) { printf("%d",*a); a++; } } Which Statement is/are True w.r.t the above code? I.Executes Successfully & Prints the contents of the array II.Gives the Error:Lvalue Required III.The address of the array should not be changed IV.None of the Above. A)Only I B)Only II C)II & III D)IV

4 Answers   Accenture,


Tell us bitwise shift operators?

0 Answers  


What is the need of structure in c?

0 Answers  


write program on arrays

3 Answers   GE, Polycab,


Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.

6 Answers  






how to generate the length of a string without using len funtion?

4 Answers  


what will be the output for the following main() { printf("hi" "hello"); }

5 Answers   RoboSoft,


write a program of bubble sort using pointer?

3 Answers   TCS,


What is an arrays?

0 Answers  


How would you sort a linked list?

1 Answers  


main() { int i; for(i=0;i<5;i++) printf("%d",1l<<i); } why doesn't 'l' affect the code??????

1 Answers  


How would you use the functions fseek(), freed(), fwrite() and ftell()?

0 Answers   Aspire, Infogain, TISL,


Categories