answersLogoWhite

0


Best Answer

include <iostream>

using namespace std;

int main() {

int n; // number to convert to binary

while (cin >> n) {

if (n > 0) {

cout << n << " (decimal) = ";

while (n > 0) {

cout << n%2;

n = n/2;

}

cout << " (binary) in reverse order" << endl;

} else {

cout << "Please enter a number greater than zero." << endl;

}

}

return 0;

}//end main

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a C program to add an integer and a decimal number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program that converts a decimal number to nearest integer?

prompt x floor(x + .5) -&gt; x disp x


How do you write 5 as an integer?

5 is an integer; it is a whole number without a decimal or fraction.


Write 1550 as a mixed number and as a decimal?

1550 is an integer and cannot be expressed as a mixed number. As a decimal, it is 1550 - exactly as in the question.


How do you write a program to find number of zeros for the given number in c program?

Assuming the number is represented by a decimal integer, initialise a counter to zero, then repeatedly divide the number by 10 and until the number is zero. After each division, examine the remainder. Each time the remainder is zero, increment the counter. If the number is represented by a decimal float, repeatedly multiply by 10 until the value is an integer, then perform the previous algorithm.


How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement


How do you write a Java program to convert a decimal number to an octal number?

public class Dataconversion { public static void main(String[] args) { System.out.println("Data types conversion example!"); int in = 44; System.out.println("Integer: " + in); //integer to binary String by = Integer.toBinaryString(in); System.out.println("Byte: " + by); //integer to hexadecimal String hex = Integer.toHexString(in); System.out.println("Hexa decimal: " + hex); //integer to octal String oct = Integer.toOctalString(in); System.out.println("Octal: " + oct); } }


How do you Write a C program to reverse an Integer number.?

Reference:cprogramming-bd.com/c_page2.aspx# reverse number


How do you write the value of a decimal?

You first write the integer part, then write the decimal point and then the fractional part in decimal form.


Write a C program to convert hexadecimal number into decimal number?

pongada punda vayanungala ..................


How do you write an integer?

The reason you're having so much difficulty writing it is that there's no such thing as an "interger". An "integer" is a whole number. Any time you write a number that doesn't have any fraction or decimal in it, you have written an integer.


How do you write nineteen as a decimal?

Since 19 is an integer, it does not require a decimal point.


Write a program to subtract integer y from integer x?

x -=y;