OneBite.Dev - Coding blog in a bite size

declare a float number in C++

Code snippet on how to declare a float number in C++

float price = 9.99;

This code declares a float number named “price” and assigns it the value 9.99. The keyword “float” tells the compiler that a decimal number is being declared. The equals sign is used to assign the value to the variable. The number 9.99 is the value that is being assigned to the variable named “price”. In this instance, the variable “price” will hold the value 9.99 until it is changed manually or by the program.

c-plus-plus