How to develop a program using C language to convert 8-bit
binary values to decimals. TQ

How to develop a program using C language to convert 8-bit binary values to decimals. TQ..

int arr[8];
int sum = 0;
int n = sizeof(arr) / sizeof(arr[0]);//24/4=6
for (int i = 0; i < n; i++) {
cout << "enter binary number
" << "index " << i << ":";
cin >> arr[i];
}

for (int i = 0; i < n; i++) {

if (arr[i] == 1) {
sum += pow(2,i);
}
}
cout << sum << endl;

 Is This Answer Correct ? 0 Yes 0 No

More C C++ Errors Interview Questions

Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

how to convert decimal to binary in c using while loop without using array

what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }

what is the large sustained error signal that eventually cause the controller output to drive to its limit

full c programming error question based problem

what is macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?

Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .

WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }

void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?

What is probability to guarantee that the task a programmer is going to create will be created and be able to run on a particular system (RTOS/GPOS).

errors are known as?

How to reverse a linked list without using array & -1? Thank you.

Categories