How do you divide 2 numbers using c plus plus?

1 answer

Answer

1288187

2026-08-09 09:30

+ Follow

Basic code in C++ for division would be:

int a = 2;

int b = 2;

int c = a / b;

A more advanced application would be to allow the user to specify the variables:

#include <iOStream>

int num1;

int num2;

std::cout << "What is the first number?";

std::cin >> num1;

std::cout << "What is the second number?";

std::cin >> num2;

std::cout << num1 / num2 << endl;

This program will not account for variables which are entered other than integers.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.