Writer a c program ( because I can't get it) | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
0

Writer a c program ( because I can't get it)

8. There are four types of fruits Apples, Oranges, Bananas and Grapes. Each student can pick up two fruits. There are some conditions which have to be used to pick up the fruits. Draw a flow chart which can take the name of first fruit as an input and print the names of second fruit or fruits that can be picked up. The conditions are: ‚ÄĘ If you pick an apple you can pick banana. ‚ÄĘ If you pick orange you can pick grapes. ‚ÄĘ If you pick grapes you can pick banana. Hint: There will be one input box to read the first fruit, three decision boxes and four output boxes in the flowchart. Use ‚Äú ‚Äú for string and == operator. #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=="ora

26th Apr 2021, 4:22 AM
KODURU VIVEK SAI REDDY
KODURU VIVEK SAI REDDY - avatar
4 Respostas
+ 1
#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); } } } '
26th Apr 2021, 4:25 AM
KODURU VIVEK SAI REDDY
KODURU VIVEK SAI REDDY - avatar
+ 1
Here is the full program
26th Apr 2021, 4:26 AM
KODURU VIVEK SAI REDDY
KODURU VIVEK SAI REDDY - avatar
26th Apr 2021, 4:30 AM
KODURU VIVEK SAI REDDY
KODURU VIVEK SAI REDDY - avatar
0
Use fgets() or scanf() to get fruit name input. gets() is not good for reading input. http://www.cplusplus.com/reference/cstdio/fgets/ http://www.cplusplus.com/reference/cstdio/scanf/ Use strcmp() to compare string content http://www.cplusplus.com/reference/cstring/strcmp/ (Edit) Move your code bit link up to the original post Description ‚ėĚ And please use proper tags https://code.sololearn.com/W3uiji9X28C1/?ref=app
26th Apr 2021, 4:44 AM
Ipang