Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hello i have c assignment homework could you help me there are one text and one

ID: 3725207 • Letter: H

Question

hello i have c assignment homework could you help me
there are one text and one image

operations.c :


Part 1. Compile and run createDat.c and figure out what happens. Pay special attention to the parameters to fopen for binary files. Then, run the program named operations.c. In this code, you will see some operations like add record, delete record etc. After nderstanding the code and the existing operations, you will make the following extensions to this code. (a) Read all structs from the binary file credit.dat (which was created after rnning create- Dat.c) and store into an array of structs. Then, pass this array and its size to a function called printArray, which print will print the contents of this array. You have to use pointer notation within the function. You should not use square brackets inside the print.Array method. (b) Add an updateRecord method to the code (This method should be called for choice-2.) Read from the keyboard the account umber to be updated. Then, you need to check if there is an existing account with the given number. If not, you should print an er- ror message. Otherwise, you will take the transaction from keyboard and update only the account balance of user. In particular, first ask the user if she wants to deposit or withdraw money, and the amount. Then update the balance. Part 2. Write a program that reverses the order of the bits in an unsigned int value. The program should input the value from keyboard and call a function reverseBits(value), that will reverse the bits and print the bits before and after reversing. Part 3. Left shifting an unsigned int value is equivalent to multiplying that value by 2. Write a function power2(number, pow) that calculates numberUse the shift operator to calculate the result. Print the value and the result as integers and as bits. Part 4. What does the following function do? int multiple( int num ) t int i; int mask = 1; int multiple = 1; for (i = 1; i

Explanation / Answer

Answer to part 2 : reverseBits(value) function :--

// c program to reverse bits of a given integer .
#include <stdio.h>

// reverseBits function .
int reverseBits(int n)
{
int a,b=0 ;
while(n > 0) // while loop .
   {
   a = n % 10 ; // a stores the remainder of division of n by 10 .
   n = n / 10; // n is divided by 10 to reduce (discard) the end digit .
   b = 10 * b + a ; // a is added to b to reverse the Bits .
   }
  
   printf("%d",b);
return 0;
};

int main(void) {
   unsigned int n ;
   scanf("%d",&n); // taking input n .
   printf("Before reversing the bits the value was %d ",n);
   printf(" After reversing the bits the value becomes ");
  
   reverseBits(n); // calling function reverseBits .
   return 0;
}

Answer to part 3 : power2(number, pow) function :--

// c program to implement function power2(number, pow)
#include <stdio.h>

// function to convert decimal to binary .
unsigned fn(unsigned k) {
if (k == 0) return 0;
if (k == 1) return 1;   
return (k % 2) + 10 * fn(k / 2);
};

// function power2(number, pow)
int power2(long long int n, int p)
{
while(p > 0) // while loop running p times thus p times doing left shift
{ // and thus the number gets multiplied by 2 p times i.e. number * 2pow .
n = n << 1 ; // left shifting numer by 1 bit
p--; // decrement p .
}
printf("the result is = %lld and in bitwise it is = %d ",n,fn(n));
return 0;
};

int main(void) {
  
   int n,p ;
   printf("Enter a number and power ");
   scanf("%d %d",&n,&p);
   printf("the value is = %d and in bitwise it is = %d ",n,fn(n));
  
   power2(n, p); // calling function power2 .
  
   return 0;
}