My issue
My code
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int x,y;
cin>>x>>y;
cout<<"x*y"<<endl;
}
return 0;
}
Problem Link: BIRYANI Problem - CodeChef
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int x,y;
cin>>x>>y;
cout<<"x*y"<<endl;
}
return 0;
}
Problem Link: BIRYANI Problem - CodeChef
@jayanth149
Anything enclosed within double quotes here will print it literally, as a string. In your code;
cout<<"x*y"<<endl;
It will print the string x*y as it is enclosed within double quotes, " ".
To get the the calculated result, just write the calculation without double quotes like this;
cout<<x*y<<endl;
In your code, instead of printing the actual product of x
and y
, you’re printing the string "x*y"
as the output. To fix this, you need to modify the line cout<<"x*y"<<endl;
to cout << x * y << endl;
. This will print the product of x
and y
instead of the string.
corected code
include
using namespace std;
int main() {
int t;
cin >> t;
while (t–) {
int x, y;
cin >> x >> y;
cout << x * y << endl;
}
return 0;
}
Now, when you input the values of `x` and `y`, the code will correctly calculate their product and print the result.