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"
Answer Posted / 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 View All Answers
Can 'this' pointer by used in the constructor?
Explain what is a pragma?
The file stdio.h, what does it contain?
What is indirection? How many levels of pointers can you have?
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
a program that can input number of records and can view it again the record
Explain what does it mean when a pointer is used in an if statement?
Does * p ++ increment p or what it points to?
What is header file definition?
how do you execute a c program in unix.
What are structural members?
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none
What is meant by initialization and how we initialize a variable?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?