A Binary no. is given, we hav to find it's decimal
equivalent.
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / bunker
include<stdio.h>
include<conio.h>
void main()
{
int n,x,a,i;
printf("ENTER THE DECIMAL NO");
scanf("%d'&n);
for(i=2;i<=n;i++)
x=n%2;
a=x/2;
printf("binary %d",a);
getch();
}
Is This Answer Correct ? | 6 Yes | 24 No |
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
5 Answers ADP, Amazon, HCL, IBM, Infosys, Satyam, TCS, Vimukti Technologies,
write a program that reverses the input number of n.Formulate an equation to come up with the answer.
Write code for the multiplication of COMPLEX numbers?
using friend function find the maximum number from given two numbers from two different classes.write all necessary functions and constructor for the classes.
main(){int a=5,b 10,c=2, d;a=b c;d=++a=(--c)*2; printf("%d%d%d%d,a,b,c,d; return o;}
Find the maximum product of three numbers in an array? Eg. 9,5,1,2,3 Max product= 9*5*3= 135 The array can hav negative numbers also..
Write a program that print in screen a tree with its height taken from user by entering number of 4 digits and find the odd numbers then calculate the sum of odd numbers so he get the height of tree?
Write a program using one dimensional array that searches a number and display the number of times it occurs on the list of 12 input values. Sample input/output dialogue: Enter 12 values: 13 15 20 13 30 35 40 16 18 20 18 20 Enter number to search: 20 Occurences: 3
write a function – oriented program that calculates the sum of the squares from 1 to n. thus, if the input is 3, the output is 14
How to swap two ASCII numbers?
write a function -oriented program that generates the Fibonacci, the current numbers of n(as input) and display them (series). In Fibonacci, the current third number is the sum of the previous number.
write a program that accepts a number and outputs its equivalent in words. take note that the maximum input is 3000