Basic arithmetic , need help! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Basic arithmetic , need help!

I need help with the division problem with decimals!

15th Oct 2021, 1:30 AM
Marcel Santos
Marcel Santos - avatar
9 Answers
+ 2
#include <iostream> using namespace std; int main() { int crabs,x; int dish=3; cin >> crabs; //your code goes here x = crabs / dish ; cout << x; return 0; } You don't need to take input for dish.In problem, it say how many trio can be made ,trio means 3 We need to do is to divide input(crabs) by 3. And you we don't need to use double data type,if do, it will print output in decimal points , just use integer data type
15th Oct 2021, 2:41 AM
Myo Thuzar
Myo Thuzar - avatar
+ 1
Its division with decimals #include <iostream> using namespace std; int main() { double crabs , dish , x ; cin >> crabs; cin >> dish; double x = crabs / dish ; cout << x; return 0; }
15th Oct 2021, 1:35 AM
Marcel Santos
Marcel Santos - avatar
+ 1
You are a cook in a restaurant. You need exactly 3 crabs to cook your special seafood dish named "Trio". Write a program that will take the number of crabs as input and output how many "Trio" dishes can be made. Sample Input 14 Sample Output 4
15th Oct 2021, 1:37 AM
Marcel Santos
Marcel Santos - avatar
+ 1
Myo Thuzar Thanks im new and been strugguling
15th Oct 2021, 2:50 AM
Marcel Santos
Marcel Santos - avatar
0
You don't need input for that <dish>. It's a fixed value of 3. So don't read input for <dish> instead assign <dish> value as <dish> was defined.
15th Oct 2021, 2:41 AM
Ipang
0
Marcel don't worry,we all once were beginners
15th Oct 2021, 2:53 AM
Myo Thuzar
Myo Thuzar - avatar
0
Myo Thuzar Would you mind expalaing somethimg to me? Ive been struggling to find a good explanation for what a framework is , ive look at a lot of vids but just cant get it … sooo could you explain it to someone who litteraly know zero about it , please
15th Oct 2021, 2:59 AM
Marcel Santos
Marcel Santos - avatar
0
Marcel man I saw you posted question about framework in your next question and someone commented under your post. It is better to read that threads
15th Oct 2021, 3:03 AM
Myo Thuzar
Myo Thuzar - avatar
- 1
#include <iostream> using namespace std; int main() { int crabs,dishes,crabs_per_dish = 3; cin >> crabs; //your code goes here dishes = crabs/crabs_per_dish; cout << dishes; return 0; }
10th Jan 2022, 1:21 AM
Naveed Abbas
Naveed Abbas - avatar