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 “
Output: "We Are Student"



Write a program that accepts a string where multiple spaces are given in between the words. Print ..

Answer / vadivel t

#include<stdio.h>
main()
{
char *p, *q, *q1;
p = (char *)malloc(200);
q = (char *)malloc(200);
q1 = q;
printf("ENTER THE SENTENCE: \n");
p = gets(p);
while(*p != '\0')
{
if(*p != ' ' || *(q -1) != ' ')
{
*q++ = *p++;
}
else
p++;
}
*q = '\0';
printf("%s", q1);
getch();
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What does s c mean on snapchat?

0 Answers  


#include<std.h> int main() { char *str[]={"Frogs","Do","Not","Die","They","Croak!"}; printf("%d %d\n",sizeof(str),strlen(str)); ...return 0; } what will the output of the above program?

6 Answers  


a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? a.infinite b.5 c.4 d.6

7 Answers   TCS,


Write a function that accepts two numbers,say a and b and makes bth bit of a to 0.No other bits of a should get changed.

2 Answers   Scientific Atlanta, Wipro,


a C prog to swap 2 no.s without using variables just an array?

5 Answers   TCS,






When should a type cast be used?

0 Answers  


Table of Sudoku n*n

0 Answers  


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

0 Answers  


how does the C compiler interpret the following two statements p=p+x; q=q+y; a.p=p+x; q=q+y b.p=p+xq=q+y c.p=p+xq; q=q+y d.p=p+x/q=q+y

4 Answers   TCS,


Why do u use # before include in a C Progam?

9 Answers   IBM,


main() { char ch='356'; Printf("%d",ch); } *OUTPUT*:- -18 *Why?*

1 Answers  


Write a program to print ASCII code for a given digit.

0 Answers   EXL, HCL,


Categories