Advertisement

C++ Program to initialize more than one variable at a time


In this program, You will learn how to initialize more than one variable at a time in C++.


x = y = z = 5

Example: How to initialize more than one variable at a time in C++

#include<iostream>
using namespace std;

int main() {
    int x, y, z;
    x = y = z = 5;

    cout << "The x value is :" << x;
    cout << "\nThe y value is :" << y;
    cout << "\nThe z value is :" << z;

    return 0;
}

Output:

The x value is :5
The y value is :5
The z value is :5