0
It can't getting print the apple where which is true
#include<stdio.h> void main() { char ch,ch1,x,y,z,u; printf("x = apple\ny = oranges\nz = grapes\nu = bananas\n"); printf("Enter the character = "); scanf("%c",&ch); if(ch==x){ printf("Apple"); } }
5 Answers
+ 2
You must assign value to variables if you want to check their values.
printf just prints something on the screen, "x = apple" is not declararion, you are telling printf to print it, nothing more.
Btw you cannot assign strings to char. You have to make char pointer or char array (string), and even if you will do, you can't compare these strings with == operator. There is that library <string.h>, which includes lots of useful function to manipulate strings, it should help you if you'll check it (find that library on the internet)
+ 1
Can any one explain
+ 1
You have not assigned any value to x. You’ve only printed that out. Assign all those variables.
0
#include<stdio.h>
#include<string.h>
void main()
{
printf("Picking of fruit\n");
printf("PICK ANY TWO FRUITS FROM \nAPPLE\nBANANA\nGRAPE\nORANGE\n");
char "apple","orange","banana","grape";
char i[10];
int n;
gets(i);
n = 0;
while(n<2)
{
if (i=="apple"||i=="Apple")
{
printf("U CAN PICK BANANA also\n");
}
else if(i=="orange"||i=="Orange")
{
printf("U CAN PICK GRAPES also\n");
}
else if(i=="grapes"||i=="Grapes")
{
printf("U CAN PICK BANANA also\n");
}
else if(i=="banana"||i=="Banana")
{
printf("U CAN PICK APPLE also\n");
}
n+=1;
if(n<2)
{
gets(i);
}
}
}
'
0
See it let me know
Hot today
I have made a calculator in which my % (Percentage) not work correctly for 100%50 or 100%20.
3 Votes
Python palindrome challenge.
1 Votes
Java
0 Votes
Number of Ones ( C++ ) question!
1 Votes
For Moderators
1 Votes