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
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 |
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 |
What are the 32 keywords in c?
Can a variable be both const and volatile?
what is difference between array of characters and string
What is pivot in c?
#include<stdio.h> main(0 { printf("\n %d %d %d",sizeof(3),sizeof("3"),sizeof(3)); }
What are the differences between Structures and Arrays?
main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } what is the output?
If I want to initialize the array like. int a[5] = {0}; then it gives me all element 0. but if i give int a[5] = {5}; then 5 0 0 0 0 is ans. what will I do for all element 5 5 5 5 5 in a single statement???
question-how to run a c programme.
What is static memory allocation?
What is meaning of tree
What is a global variable in c?