What is wrong with this code such that it doesnt produce
the input reversed?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
char Space = ' ';
char LineOfText;
float count;

LineOfText = getchar();

while ((LineOfText = getchar()) != '/n');
{
count = strlen(LineOfText) - 1;
while (count >= 0)
{
putchar(LineOfText[count]);
count--;
}

}
getchar();
return 0;
}

Answers were Sorted based on User's Feedback



What is wrong with this code such that it doesnt produce the input reversed? #include <stdio.h..

Answer / ashok kumar

Actually the function strlen() returns an integer value,
but here we want to try to push that value to the float
variable. To rectify this problem declare the variable
"count" as int.

Is This Answer Correct ?    1 Yes 0 No

What is wrong with this code such that it doesnt produce the input reversed? #include <stdio.h..

Answer / sanjay bhosale

LineOfText is not an array of characters.
first while loop only stores '/n' in lineOfText.
We cant apply strlen on character we should pass the address of character array to it.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is self-referential structure in c programming?

0 Answers  


List a few unconditional control statement in c.

0 Answers  


1.find the second maximum in an array? 2.how do you create hash table in c? 3.what is hash collision

9 Answers   HCL, Qualcomm,


What is hungarian notation? Is it worthwhile?

0 Answers  


write a C code to reverse a string using a recursive function, without swapping or using an extra memory.

9 Answers   Motorola, TCS, Wipro,






Explain low-order bytes.

0 Answers  


Write a program for print infinite numbers

3 Answers   Wipro,


What is bubble sort technique in c?

0 Answers  


Is c call by value?

0 Answers  


application attempts to perform an operation?

0 Answers  


why do some people write if(0 == x) instead of if(x == 0)?

0 Answers  


input any 4 digit number and find the difference of all the digits?

3 Answers   Google,


Categories