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

Write code in C please. Part 2: A safe calculator (100 points) In this project,

ID: 3722246 • Letter: W

Question

Write code in C please.

Part 2: A safe calculator (100 points) In this project, you will write a safe signed integer calculator. As with Part 1, some of the code is completed for you and there are descriptions and comments to help. You should not use any arithmetic operators, except simple assignment, or increment and decrement operators in your code. The_add), an add function that only uses bitwise operators, and add(), a safe add function that detects and reports overflow and underflow errors, are crucial to the other functions. The seven remaining functions either directly or indirectly depend on_add() and add(). Code these functions to in their order to maintain functional dependencies. Use the main function to test each function before continuing to the next function 1. 2. 3. Negation is defined using a bitwise operator and the add() function Subtraction is defined using Negation and add() functions Multiplication is defined with successive add() function and Subtraction function calls a. Should perform with positive integers and keep track of which sign the product has 4. Division is defined with successive Subtraction and add) function calls 5. Modulus is defined as successive calls to Subtraction to return a remainder 6. Power is defined as successive calls to Multiply and Subtraction 7. Convert converts an input string to an integer value Should perform with positive integers and keep track of which sign the result has Should perform with positive integers Only use positive exponents Pay attention to comments - This is the longest function a. a. a. a. b. You may be able to modify your dec_to_uint() from Part 1

Explanation / Answer

CODING:

#include<conio.h>

#include<stdio.h>

void main()

{

int n1,n2,i,prod=0,i,j, borrow,a,b,count=0;

int x, n, p, q, m;

int answer,increment, str;

unsigned long mult ;

unsigned long re;

int len;

clrscr();

printf("Enter 1st number: ");

scanf("%d",&n1);

printf("Enter 2nd number: ");

scanf("%d",&n2);

printf("Addition without arithmetic operator: ");

while(n2--)

{

n1++;

}

printf("addition result:%d "n1);

printf("subtraction without arithmetic operator: ");

while (n2!= 0)

{

borrow = (~n1) & n2;

n1 = n1 ^ n2;  

n2= borrow << 1;

}

printf("subtraction result %d", n1);

printf("product without arithmetic operator: ");

for(i=1;i<=n2;i++)

{

prod+=n1;

}

printf(" Product of %d and %d is %d",n1,n2,prod);

printf("division without arithmetic operator: ");

n1 = a;

n2 = b;

while(n1 >= n2)

{

n1 = n1 - n2;

count++;

}

printf(" Division of %d and %d: Quotient: %d Remainder: %d ", a, b, count, n1);

printf("module without arithmetic operator: ");

printf("Enter x and n: ");

scanf("%d%d", &x, &n);

//mod

q = x / n; //finding quotient (integer part only)

p = q * n; //finding product

m = x - p; //finding modulus

//output printf("Modulus: %d ", m);

printf("power without arithmetic operator: ");

if (b == 0)

return 1;

answer = a;

increment =a;

for(i = 1; i < b; i++)

{

for(j = 1; j < a; j++)

{

answer += increment;

}

increment = answer;

printf("power: %d ", answer);

printf("convert string into integer: ");

mult = 1;

re = 0;

printf("Enter string to convert into integer: ");

scanf("%s",&str);

len = strlen(str);

for(i = len -1 ; i >= 0 ; i--) {

re = re + ((int)str[i] -48)*mult;

mult = mult*10;

}

printf("converted string: %d",re);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote