Exercise: Declaration and Initialization Of Data Types

Test your understanding of data types and initialization of declared variables in C++

Problem Statement

You have been given a task to perform a list of variable declarations, assigning values and printing the output on the console. Here are the types of declarations we need to perform:

  • Declare an integer type variable name intNumber and assign it a value of 30.

  • Declare a float type variable name floatNumber and assign it a value of 30.78.

  • Declare a double type variable name doubleNumber and assign it a value of 45.1234.

  • Declare a bool type variable name boolean and assign it a value of true.

  • Declare a char type variable name charName and assign it a value of u.

  • Lastly, print the values of all declared variables.

Expected output

At the end, your program should be able to display the following output:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy