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

Why do some versions of toupper act strangely if given an upper-case letter?

0 Answers  


what is computer engg

1 Answers  


Why is C called a middle-level language?

1 Answers  


When do we get logical errors?

0 Answers  


what are two kinds of java

2 Answers  






write a program to rearrange the array such way that all even elements should come first and next come odd

0 Answers  


Explain logical errors? Compare with syntax errors.

0 Answers  


How do shell structures work?

0 Answers  


What language is lisp written in?

0 Answers  


Question 1: You want to conduct a survey within your classroom, on the quality of canteen’s food. You ask each of your class fellows to rank the quality of food between 1 and 5 (1 representing excellent quality and 5 representing worst quality). During the survey, you make a list containing the roll# of student and the opinion given by that student. The list can be as follow Roll # Opinion 234 1 235 1 236 5 237 1 238 2 239 3 240 5 241 5 242 1 To get the results of the survey, you need to determine the frequency of each opinion value. The frequency of an opinion is determined by counting the number of students giving that opinion. For example, for the above list the frequency of opinion value 1 is 4 and frequency of opinion value 4 is 0. After getting the frequency of each opinion, you can easily judge about the quality of the food by seeing through the frequency of each opinion. You need to develop a program to calculate the results of this survey. The program inputs the opinion of 50 students and counts the frequency of each opinion. It then displays a report showing the frequency of each opinion. Sample output: Opinion Frequency Remarks 1 5 Excellent 2 10 Good 3 15 Normal 4 10 Bad 5 10 Really bad

1 Answers  


What is the use of ?: Operator?

0 Answers  


If null and 0 are equivalent as null pointer constants, which should I use?

0 Answers  


Categories