
This in C language
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;
}

Actually, program is a executable software that runs on a computer.
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- Write a C++ program with two user defined functions. The first function named "functionWithArray" takes two user input arguments of character types and return True if first argument is smaller than the second argument (alphabetically) and returns False otherwise. Write the second function named "functionWithPointers" which behaves like the first functions but uses pointers to receive the arguments. You may assume that both character arrays contain only lower-case letters, and no blanks or other non- alphabetic characters. Write a suitable Main function to test these two functions. Sample Output: Enter First String: C++Programming Enter Second String: JavaProgramming According to functionWithArrays: 'c++programming' is smaller than 'javaprogramming'. According to functionWithPointers: 'c++programming' is smaller than 'javaprogramming'.arrow_forwardC++ Programming Request an integer n from the console.Write a function that accepts n as input and outputs the multiplicationtable of n from 1 to n to the console. Example Output: Enter an integer: 91 * 9 = 92 * 9 = 183 * 9 = 274 * 9 = 365 * 9 = 456 * 9 = 547 * 9 = 638 * 9 = 729 * 9 = 81arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





