Old 04-21-2014, 02:05 AM   #1 (permalink)
Status: Senior Member
Posts: 766

Default c code question

Write a computer program in the C language that reads two binary numbers from the standard input (keyboard) and outputs their sum, difference, and product (in binary format) to the standard output (monitor).

this is what i have so far, im so fucking lost

#include <iostream>
using namespace std;

int main() {
int firstInt; // Declare a variable named firstInt of the type int (integer)
int secondInt; // Declare a variable named secondInt of the type int
int sum, difference, product, quotient;
// Declare 4 variables of the type int to keep the results

cout << "Enter first integer: "; // Display a prompting message
cin >> firstInt; // Read input from keyboard (cin) into firstInt
cout << "Enter second integer: "; // Display a prompting message
cin >> secondInt; // Read input into secondInt

// Perform arithmetic operations
sum = firstInt + secondInt;
difference = firstInt - secondInt;
product = firstInt * secondInt;
quotient = firstInt / secondInt;

// Print the results
cout << "The sum is: " << sum << endl;
cout << "The difference is: " << difference << endl;
cout << "The product is: " << product << endl;
cout << "The quotient is: " << quotient << endl;

return 0;
Smile.ToMe is offline   Reply With Quote



Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help.. Question in VB 2010. Cant figure out how to writhe code for my question? Matt Coding 1 06-25-2013 02:06 AM
Source Code Problem? See Question for Code? TodayIBUY Html Code/ Html Codes 0 12-10-2012 02:05 AM
Source Code Problem? See Question for Code? Sarah69 Html Code/ Html Codes 1 12-06-2012 10:05 PM
Java question: How to fix the code so I get element instead of index( code given ) Heireefek Coding 1 08-17-2011 03:52 AM
Java question:), how to print a code with a return statement(code given) ladyrussian20 Coding 2 08-12-2011 09:07 PM