Computer Programming Learning Part-04||Week-04||C++ program to divide two numbers using floating number.

in Steem4Professionalslast month

Steemian Friends,
Today, I will write Computer Programming Learning Part-04. I will show floating-number programming in a C++ program. In the previous parts, I have shown programming with integer numbers. Hopefully, I can learn C++ programs with floating numbers from today's learning part. Today, I will show a C++ program to divide two floating numbers.

Programming Learning Part 04.png
Design By Canva

Floating number:
We do addition, subtraction, and multiplication with Integer numbers. But decimal numbers are called floating to program in C++. There are two types of floating numbers: single floating and double floating. Single floating is 32 bits, and double floating is 64 bits. Today, I will show a C++ program with Single Floating as an example. So, let's begin.

IMG20240523145329.jpg

IMG20240523145424.jpg


Step 01:

I first open the Block Codes software. Then I go to File and click on New. Then, I click on the Empty File option and turn on the program writing page. I have shown it as a red block in the picture below.

1.png

2.png

3.png


Step 02:

Then, I will declare the Header file and Main function. Every C++ program has to write these two parts at the beginning. I have written it below.

#include<stdio.h>
int main ()
{}


Step 03:

Then, I declared a floating variable, which is written with a and b. It is written below.

float a;
float b;


Step 04:

Then, I declared two floating numbers, which will sit as the values ​​of a and b. Two floating numbers are a=9.5 and b=7.3. Below is the program written.

a= 9.5;
b=7.3;


Step 05:

Then, I will divide the above two floating numbers. I have written the following C++ program to divide the floating number and see the result.

Printf (" result : %f\n",a/b);
return 0 ;

Completed the program with

5.png


Step 06:

Then I read the entire program once. Then, I clicked on the Run program option. Then, I looked at the bottom of the program; there was no error. If there had been a mistake, it would show the error in red letters at the bottom. There are no errors in writing my program.

6.png


Step 07:

Then I see the program's output. It shows the result of dividing two floating numbers. The result shows six digits after the decimal point. Two or three numbers can be shown after the decimal if desired.

7.png


Step 08:

Then, I have written below the work to be done to display three digits after the decimal of the result.

Printf("result : % 0.3 f\n",a/b);

Blue line.png

Link to my previous post:

Part-01

Part-02

Part-03

Blue line.png

Steemit.com.png

Thank you for reading my post, and I am leaving today. Allah Hafez.

image.png

Sort:  

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)

The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.


We support quality posts and good comments posted anywhere and with any tag.

Curated by : @𝗁𝖾𝗋𝗂𝖺𝖽𝗂

 last month 

Thank You Dear Sir....

Loading...

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.029
BTC 56608.36
ETH 2976.28
USDT 1.00
SBD 2.15