Question

Please help with this. Modify the program Figure 2.6 (exam1/exam2). Ask the user to enter two...

Please help with this.

Modify the program Figure 2.6 (exam1/exam2). 
Ask the user to enter two numbers
Find the result when the first number is divided by the second
Also find the remainder when the first number is divided by the second

In other words, the program used to do this:
68  85
score = 81

Now it should do this 
22 2
Divide = 11  Remainder = 0
If you run it again:
11 2
Divide = 5   Remainder = 1
If you run it again:
20 16
Divide = 1   Remainder = 4

Use integer arithmetic only. NO DECIMAL POINTS.

This is my code

#include <stdio.h>
#include <stdlib.h>


int main(int argc, char** argv) {
  
const int bonus = 10;
int exam1;
int exam2;
int score;

scanf("%d%d", &exam1, &exam2);
score = (exam1 + exam2) / 2 + bonus;
printf("score - %d\n", score);

return (0);
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*
 *  C Code for demonstrating division
 */

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv)
{  
  const int bonus = 10;
  int exam1;
  int exam2;
  int divide, remainder;

  scanf("%d%d", &exam1, &exam2);

  divide = exam1 / exam2;
  remainder = exam1 % exam2;

  printf("Divide = %d, Remainder = %d\n", divide, remainder);

  return (0);
}

Add a comment
Know the answer?
Add Answer to:
Please help with this. Modify the program Figure 2.6 (exam1/exam2). Ask the user to enter two...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ANSWER ASAP PLEASE IN C Duplicate the program below to a new Program 2, and modify...

    ANSWER ASAP PLEASE IN C Duplicate the program below to a new Program 2, and modify Program 2 such that it generates n random virtual addresses between 0 and 232-1 and computes the page number and offset for each address. Here, do not write to the console. Instead, run your program with n = 1000000 random virtual addresses and compute the total CPU time of the task. Report your findings, as well as how you ran your program. Provide commentary...

  • My question is listed the below please any help this assignment ; There is a skeleton...

    My question is listed the below please any help this assignment ; There is a skeleton code:  copy_file_01.c #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) { char ch ; FILE *source , *target;    if(argc != 3){ printf ("Usage: copy file1 file2"); exit(EXIT_FAILURE); } source = fopen(argv[1], "r"); if (source == NULL) { printf("Press any key to exit...\n"); exit(EXIT_FAILURE); } target = fopen(argv[2], "w"); if (target == NULL) { fclose(source); printf("Press any key to exit...\n"); exit(EXIT_FAILURE); } while ((ch...

  • I need to modify below code to have output like: Example: RBGY [ You have 1...

    I need to modify below code to have output like: Example: RBGY [ You have 1 white flag and you have 1 red flag] Example: CCGG [ You have 0 white flag and you have 1 red flag] ================================== #include <stdio.h> #include <string.h> #include <time.h> #include <stdlib.h> #define SIZE_STRING 4 #define SIZE_STRING_LONG 15 int main(int argc, char *argv[]){ if(argc != 2) { printf("Usage: ./main <scComputer>"); exit(0); } char szUser[SIZE_STRING_LONG]; char *szComputer = argv[1]; int counter=0; int colour=0; int position=0; char...

  • In the Source Folder (src) of this project create a new C source file called "gcd.c"....

    In the Source Folder (src) of this project create a new C source file called "gcd.c". Once again, copy the contents of the "main.c" file above into the "gcd.c" source file. Modify this program to NOT ask the user to input the second Positive Integer, if the user has entered a program terminating value for the "first" input Postitive Integer. #include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { //============================== setbuf(stdout, NULL); // turns standard output buffering off int...

  • Please write MIPS program that runs in QtSpim (ex: MipsFile.s) Write a MIPS program that will...

    Please write MIPS program that runs in QtSpim (ex: MipsFile.s) Write a MIPS program that will read in a base (as an integer) and a value (nonnegative integer but as an ASCII string) in that base and print out the decimal value; you must implement a function (which accepts a base and an address for a string as parameters, and returns the value) and call the function from the main program. The base will be given in decimal and will...

  • Writing a program in C please help!! My file worked fine before but when I put...

    Writing a program in C please help!! My file worked fine before but when I put the functions in their own files and made a header file the diplayadj() funtion no longer works properly. It will only print the vertices instead of both the vertices and the adjacent like below. example input form commnd line file: A B B C E X C D A C The directed edges in this example are: A can go to both B and...

  • If you already answer this question, please skip, thanks C Programming. Fill in ... This program...

    If you already answer this question, please skip, thanks C Programming. Fill in ... This program will be called with one command line argument that contains a string followed by an asterisk and an integer. Print out the string as many time as indicated by the integer. For example, when called as prog Hi*3, you print HiHiHi. Hint: Look for the '*' starting from the back of the string. len = strlen(arg) gives you the string length. When you have...

  • Modify the client server system program given below so that instead of sendto() and recvfrom(), you...

    Modify the client server system program given below so that instead of sendto() and recvfrom(), you use connect() and un-addresssed write() and read() calls. //Server.c #include #include #include #include #include #include #include #include #include #include # define PortNo 4567 # define BUFFER 1024 int main(int argc, char ** argv) { int ssd; int n; socklen_t len; char msg[BUFFER]; char clientmsg[BUFFER]; struct sockaddr_in server; struct sockaddr_in client; int max_iterations = 0; int count = 0, totalChar = 0, i = 0;...

  • OPERATING SYSTWM Question 31 What is the output of this C program? #include #include void main()...

    OPERATING SYSTWM Question 31 What is the output of this C program? #include #include void main() int mptr, *cptr mptr = (int*)malloc(sizeof(int)); printf("%d", "mptr); cptr = (int)calloc(sizeof(int),1); printf("%d","cptr); garbage 0 000 O garbage segmentation fault Question 8 1 pts If this program "Hello" is run from the command line as "Hello 12 3" what is the output? (char '1'is ascii value 49. char '2' is ascii value 50 char'3' is ascii value 51): #include<stdio.h> int main (int argc, char*argv[]) int...

  • C programming Question1 (a) Write a C program that will print out all command line arguments,...

    C programming Question1 (a) Write a C program that will print out all command line arguments, in reverse order, one per line. Prefix each line with its index. 6 marks] (b) Consider this C code snippet int a- 100 int b- 42; inte p- &a; int q-b; p qi printf ("%d %d\n" ,a,*p); When this code is executed, what numbers will it print? [2 marks] (c) Consider this C program int main(int argc,char argv) char* target- "Apple" char vord[100] printf...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT