C++ program that prints a text of 4 lines consisting of characters, integers values and floating-point values using cout statement.

C++
#include <iostream>

using namespace std;

int main() {
  // Declare variables
  char character = 'a';
  int integer = 123;
  float floating_point = 1.23;
  string message = "Hello, world!";

  // Print the text in 4 lines
  cout << "This is a character: " << character << endl;
  cout << "This is an integer: " << integer << endl;
  cout << "This is a floating-point number: " << floating_point << endl;
  cout << "This is a string: " << message << endl;

  return 0;
}

This program first declares 4 variables: a character variable character, an integer variable integer, a floating-point variable floating_point, and a string variable message. Then, it prints the text in 4 lines, using the cout statement. The endl manipulator is used to insert a new line at the end of each line.

To run this program, you can save it as a .cpp file and compile it using a C++ compiler. For example, on Linux or macOS, you can use the following command to compile the program:

g++ -o program program.cpp

Once the program is compiled, you can run it by typing the following command:

./program

This will print the following output:

This is a character: a
This is an integer: 123
This is a floating-point number: 1.23
This is a string: Hello, world!
Copyright © 2025 AWS Tutorials | Distributed by Blogger Templates | Designed by OddThemes