Declare and Print

Lab C++ Beginner 10 points

Declare int year = 2026, double pi = 3.14159, char grade = 'A', bool ok = true and string name = "Ada". Print them on one line separated by spaces, with ok shown as true (use boolalpha).

Input

None.

Output

One line.

Example

Output

2026 3.14159 A true Ada
Sample output available
Editor
C++

Hints

boolalpha makes bools print as true/false instead of 1/0.

Solution explanation

string (from <string>) is C++'s text type - much easier than C char arrays.

Show solution
#include <iostream>
#include <string>
using namespace std;

int main() {
    int year = 2026;
    double pi = 3.14159;
    char grade = 'A';
    bool ok = true;
    string name = "Ada";
    cout << boolalpha << year << " " << pi << " " << grade << " " << ok << " " << name << "\n";
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD