Exercise: Declaration and Initialization Of Data Types
Test your understanding of data types and initialization of declared variables in C++
We'll cover the following
Problem Statement
You have been given a task to perform a list of variable declarations, assigning values and printing the output on the console. Your job is to write a code that initializes the variables and displays them.
Sample input
Declare an
integer
type variable nameintNumber
and assign it a value of30
.Declare a
float
type variable namefloatNumber
and assign it a value of30.78
.Declare a
double
type variable namedoubleNumber
and assign it a value of45.1234
.Declare a
bool
type variable nameboolean
and assign it a value oftrue
.Declare a
char
type variable namecharName
and assign it a value ofu
.Lastly, print the values of all declared variables.
Sample output
At the end, your program should be able to display the following output:
Create a free account to access the full course.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy