Exercise: Declaration and Initialization Of Data Types

Write a code that initializes the variables and displays them.

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 named intNumber and assign it a value of 30.

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

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

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

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

  • 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