what is the weight of each cat? (c++ code for this problem) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 24

what is the weight of each cat? (c++ code for this problem)

Kion has three cats. Each has different weight. The 1st & 2nd weigh 9kg altogether. The 2nd & 3rd weigh 10kg altogether. The 1st & 3rd weigh 13kg altogether. What is the weight of each cat?

1st Dec 2016, 9:03 AM
Jobelle
Jobelle - avatar
7 Answers
+ 4
Hey, Jobelle you can use this code also with same sequence like your question. Here it is #include <iostream> using namespace std; int main() { int a,b,c,x,y,z; cout << "Please enter constant of three equcations\n"; cin >> a >> b >> c; cout << "You have entered\n" << "x+y=" << a << "\ny+z=" << b << "\nx+z=" << c << endl; x=(2*a-(a-c)-b)/2; y=((a-c)+b)/2; z=(2*b-(a-c)-b)/2; cout << "Weight of 1st cat: " << x << "\nWeight of 2nd cat: " << y << "\nWeight of 3rd: " << z; return 0; }
1st Dec 2016, 2:26 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 23
thank you so much
1st Dec 2016, 11:53 AM
Jobelle
Jobelle - avatar
+ 3
Here, it is #include <iostream> using namespace std; int main() { int a,b,c,x,y,z; cout << "Please enter constant of three equcations\n"; cin >> a >> b >> c; cout << "You have entered\n" << "x+y=" << a << "\ny+z=" << b << "\nx+z=" << c << endl; x=(2*a-(a-b)-c)/2; z=(2*c-(a-b)-c)/2; y=((a-b)+c)/2; cout << "Weight of 1st cat: " << x << "\nWeight of 2nd cat: " << y << "\nWeight of 3rd: " << z; return 0; } I have use simple algebra method. But If you want I can show you in other also. Here input sequence is matter. I have assume 1st cat as x, y as 2nd cat and z as 3rd one. I am talking about weight. so, enter your data as x+y=9 x+z=13 y+z=10
1st Dec 2016, 11:09 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 2
1st cat - 6 2nd cat - 3 3rd cat - 7 And I am going to write code.
1st Dec 2016, 9:08 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 2
Only for this one, if it x,y or z has a co-efficient then No
1st Dec 2016, 11:50 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 2
how are you prople able to build an algorithm so easily? x+y=9 nd y+z=10 nd x+z=13 other than those above codes i cant get any more further steps😢
18th May 2017, 12:46 PM
U L Knw Me soon😉😋
U L Knw Me soon😉😋 - avatar
0
@Aditya Kumar pandey will it work for any linear equation with three unknowns ?? or it for this problem specifically
1st Dec 2016, 11:46 AM
Abhishek Kumar
Abhishek Kumar - avatar