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

This is for a c++ program, please read the specifications carefully to make sure

ID: 645934 • Letter: T

Question

This is for a c++ program, please read the specifications carefully to make sure it does what it is supposed to do. This is for a 100 level class so no need to get over complicated. Thanks

Specifications: The little calculator processes several lines of character input from the terminal or from a file (your choice). On each line, it does a single integer arithmetic computation, or generates an error message. A correct line of input consists of an integer, an operator, and another integer, with zero or more blanks between each token. Programmer Option: The little calculator can process input character by character, or by reading entire line in as a string. The little calculator accepts as correct the integer operators *, /, +, -, %. The little calculator would evaluate as correct a file containing the following:

123    *     12<ret>

32000        -       500<ret>

45%20<ret>

32000 +           767<ret>

<ret>indicates Enter key.
For the last line above the little calculator would output: answer is 32767.   The little calculator needs to catch three types of errors. The following three lines would be recognized as containing errors respectively:

Explanation / Answer

#include <stdio.h>

int main()
{
unsigned int number;
int count = 0;

printf("Enter the unsigned integer: ");
scanf("%d", &number);
while (number != 0)
{
if ((number & 1) == 1)
count++;
number = number >> 1;
}
printf("number of one's are : %d ", count); 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