Write a c program | Sololearn: Learn to code for FREE!

+5

Write a c program

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.

4/26/2021 3:57:12 AM

vivek_sai 0449

18 Answers

New Answer

+8

If you are a beginner, just go through the tutorials first.. It's the program which covers the basic concept of conditional stmts.. Go through them and try it first.. If you still stuck anywhere then come here.. As they mentioned, try the flowchart first.. Using that you can automatically convert it into code by yourself. It's not that hard!!!

+6

Use strcmp as👇👇👇 https://code.sololearn.com/cONtC4NThLh9/?ref=app

+5

I did it is their any worng in this

+2

Vivek Start learning C from here and write program https://www.sololearn.com/Course/C/?ref=app

+2

#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); } } } '

+2

Just tell it

+2

+2

https://code.sololearn.com/cRF2Ep7vUPih/?ref=app

+2

// Created by Vivek #include<stdio.h> #include<string.h> int main() { printf("Picking of fruit\n"); printf("PICK ANY TWO FRUITS FROM \nAPPLE\nBANANA\nGRAPE\nORANGE\n"); char i[10]; int n; gets(i); n = 0; while(n<2) { if (!strcmp(i,"apple")||!strcmp(i,"Apple")) { printf("U CAN PICK BANANA also\n"); } else if(!strcmp(i,"orange")||!strcmp(i,"Orange")) { printf("U CAN PICK GRAPES also\n"); } else if(!strcmp(i,"grapes")||!strcmp(i,"Grapes")) { printf("U CAN PICK BANANA also\n"); } else if(!strcmp(i,"banana")||!strcmp(i,"Banana")) { printf("U CAN PICK APPLE also\n"); } n+=1; if(n<2) { gets(i); } } return 0; }

+1

Vivek It would be better & easy to trace if you provide the i/p and o/p formats..

+1

Guys if know tell me or leave it guys

+1

I am asking yesterday onwary

+1

You have to make variables to assign values to them (so you can't write char "Apple"), you can't save strings inside char, char stores single chraracter. Make char array or char pointers to save these strings. You also can't compare strings in C using == operator. This operator is comparing adresses of strings (you can compare characters, but not strings with it!) Use strcmp to compare these strings (strcmp is inside string.h header file).

+1

Vivek, you have posted this same question 3 times. Tha answer remains unchanged. The question requires you to draw a flow chart. It does not require you to write any code. You do know what a flowchart is don't you?

+1

This is the right answer

0

In turbo c++ pluss output comes hello why can u explain this main() { for(;0;) { printf("hello"); } } Output in TC++ ??

-5

https://youtu.be/AFpFD5Oi_qQ

-6