python converter to c

# Python code
def greet(name):
    return "Hello, " + name + "!"

print(greet("Alice"))
print(greet("Bob"))

C++ Equivalent

// C++ code
#include <iostream>
#include <string>
using namespace std;

string greet(string name) {
    return "Hello, " + name + "!";
}

int main() {
    cout << greet("Alice") << endl;
    cout << greet("Bob") << endl;
    return 0;
}
  1. Python code defines a function named greet that takes a parameter name and returns a greeting message.
  2. The print statements call the greet function with different names and print the result.
  3. The C++ equivalent code includes the necessary header files for input/output and string manipulation.
  4. The greet function in C++ uses the string data type and the + operator for string concatenation.
  5. In the main function, cout is used to print the results of calling the greet function with different names.
  6. The program ends with a return 0; statement to indicate successful execution. ```