Defining a binary number as Program 1, write the function int binToDec(const int bin[]) to convert an eight-bit unsigned binary number to a nonnegative decimal integer. Do not output the decimal integer in the function. Test your function with interactive input. Defining bAnd, bin1, and bin2 as binary numbers as in Program 1 above, write the void function void binaryAnd(int bAnd[], const int bin1[], const int bin2[]) to compute bAnd as the logical AND of the two binary numbers bin1 and bin2. Do not output the binary number in the function. Test your function with interactive input.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Defining a binary number as Program 1, write the function

int binToDec(const int bin[]) to convert an eight-bit unsigned binary number to a nonnegative decimal integer. Do not output the decimal integer in the function. Test your function with interactive input.

Defining bAnd, bin1, and bin2 as binary numbers as in Program 1 above, write the void function

void binaryAnd(int bAnd[], const int bin1[], const int bin2[])

to compute bAnd as the logical AND of the two binary numbers bin1 and bin2. Do not output the binary number in the function. Test your function with interactive input.

 

Program1 in  C:

#include <stdio.h>
int main()
{
int binNum[8]; // Array to read binary number
long dec=0,n=0; // variables used to convert binary to decimal
int k=0,l=0;
long binary=0;
int i=1,j=0,remainder=0;
  
//reading the binary number in to the array binNum
printf("Please Enter the first binary number with each bit seperate by at least one space : \n");
  
scanf("%d %d %d %d %d %d %d %d",&binNum[0],&binNum[1],&binNum[2],&binNum[3],&binNum[4],&binNum[5],&binNum[6],&binNum[7]);
  
//converting the binary number in to decimal
for(k=7;k>=0;k--)
{
dec=(binNum[k]*power(2,l))+dec;
l++;
}
printf("Next 10 binary numbers are as below : \n");
//Printing next 10 binary numbers by incrementing the decimal number.
//and converting the decimal number to binary after increment
for(j=1;j<=10;j++,dec++){
i=1;
remainder=0;
binary=0;
n=dec+1;
while(n != 0) {
remainder = n%2;
n = n/2;
binary= binary + (remainder*i);
i = i*10;
}
printf("%ld \n",binary);
}
  
return 0;
}
//Power function to calculate the power of 2 numbers.
int power(int c, int d)
{
int pow=1;
int i=1;
while(i<=d)
{
pow=pow*c;
i++;
}
return pow;
}

Expert Solution
Step 1

Actually, program is a executable software that runs on a computer.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education