Exercise: Declaration and Initialization Of Data Types
Write a code that initializes the variables and displays them.
We'll cover the following
Problem statement
Declare variables, assign them specific values, and print each variable to the console. Write code that initializes the variables and displays them.
Sample input
Declare an
integer
type variable namedintNumber
and assign it a value of30
.Declare a
float
type variable namedfloatNumber
and assign it a value of30.78
.Declare a
double
type variable nameddoubleNumber
and assign it a value of45.1234
.Declare a
bool
type variable namedboolean
and assign it a value oftrue
.Declare a
char
type variable namedcharName
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