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"
#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 |
How do you declare a variable that will hold string values?
What is a const pointer?
Can you return null in c?
what is the difference between structure and union?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
How can you call a function, given its name as a string?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
Do you have any idea about the use of "auto" keyword?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
How to reverse a string using a recursive function, without swapping or using an extra memory?
31 Answers Cisco, Mind Tree, Motorola, Ophio, Sony, TCS, Wipro,
what is difference between ++(*p) and (*p)++
17 Answers Accenture, HCL, IBM,
2.main { int x,j,k; j=k=6;x=2; x=j*k; printf("%d", x);