A Binary no. is given, we hav to find it's decimal
equivalent.
Answer Posted / jaydeep patel
#include <conio.h>
#include<stdio.h>
#include<iostream.h>
#include<math.h>
void main(void)
{
clrscr();
int binary,len,dec=0;
cout<<"Enter Binary No:: ";
cin>>binary;
for(int i=0;;i++)
{ if(binary==0)
break;
else
{
int temp=binary%10;
dec=dec+(pow(2,i)*temp);
binary=binary/10;
}
}
cout<<endl<<"Decimal No is:: "<<dec;
getch();
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
output for printf("printf");
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
how to take time as input in the format (12:02:13) from user so that controls remains between these columns?
write a program to calculate the amount of investment after a period n years if the principal investors was p and interest is calculated using compound interest,formular=a=p(1+r)^n
write a program to convert temperature from fa height into celcius and vise versa,use modular programming
solve the problem in the programming language C++"if a five digit number is input through the keyboard.Write a program to calculate the sum of its digits(hint: use the modulus operator)
can you please write a program for deadlock that can detect deadlock and to prevent deadlock.
How to swap two ASCII numbers?
Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.
Write a simple encryption program using string function which apply the substitution method.
What output does this program generate as shown? Why? class A { A() { cout << "A::A()" << endl; } ~A() { cout << "A::~A()" << endl; throw "A::exception"; } }; class B { B() { cout << "B::B()" << endl; throw "B::exception"; } ~B() { cout << "B::~B()"; } }; int main(int, char**) { try { cout << "Entering try...catch block" << endl; A objectA; B objectB; cout << "Exiting try...catch block" << endl; } catch (char* ex) { cout << ex << endl; } return 0; }
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
i don't know about working of nested for loop can any one help me
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...