Skip to main content

Thread: C program compiler gives wrong results


hey all!!
humble salute great souls of great community!
hope me in solving below issues
problem
started learning c. run programs in terminal. following program gives me wrong result.
#include<stdio.h>
main ()
{
char in;
puts ("enter character");
in=getchar();
fflush (stdin);
if (in!='y'|| in!='y')
puts ("you did not enter y!!");
else
puts ("there entered y sweetiee!!!");
}

in program, when enter y or y, gives me result "you did not enter y!!".
going wrong??

quote posted sreeharitk view post
hey all!!
humble salute great souls of great community!
hope me in solving below issues
problem
started learning c. run programs in terminal. following program gives me wrong result.
#include<stdio.h>
main ()
{
char in;
puts ("enter character");
in=getchar();
fflush (stdin);
if (in!='y'|| in!='y')
puts ("you did not enter y!!");
else
puts ("there entered y sweetiee!!!");
}

in program, when enter y or y, gives me result "you did not enter y!!".
going wrong??
replace if this:
code:
if ((in!='y')||(in!='y'))


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support New to Ubuntu [SOLVED] C program compiler gives wrong results


Ubuntu

Comments

Popular posts from this blog

how to devide a circle into equal parts

"Could not fill because there are not enough opaque source pixels" - not solved by any other thread

Why can't I change the billing info for my account?