What is the equivalent statement of this commented line in C++ :
#include <iostream>
int main()
{
int x, y;
cin >> x >> y;
// equivalent of this line in c++ : printf("%d\n", x > y ? x : y);
return 0;
}
What is the equivalent statement of this commented line in C++ :
#include <iostream>
int main()
{
int x, y;
cin >> x >> y;
// equivalent of this line in c++ : printf("%d\n", x > y ? x : y);
return 0;
}
You could use std::format, which is very similar to the printf function but it only appeared in C++20.
#include <iostream>
#include <format>
int main() {
int x, y;
std::cin >> x >> y;
std::cout << std::format("{0}", x > y ? x : y) << std::endl;
return 0;
}