Ad Code

NEW POST

6/recent/ticker-posts

Nancy Bought Apple || SRM ELAB DLD

c program

Nancy Bought Apple

CODE:

#include <stdio.h>
int main()
{
 int billamt,amtgiven;
 int q,r;
 scanf("%d",&amtgiven);
 scanf("%d",&billamt);
 q=amtgiven/billamt;
 r=amtgiven%billamt;
 printf("Quotient:%d\nRemainder:%d",q,r);
return 0;
}

EXPLANATION:

#include <stdio.h>  // This line includes a library that provides input/output functions.

int main() {
    // Declare variables to store the amount given and the bill amount.
    int billamt, amtgiven;

    // Declare variables to store the quotient and remainder.
    int q, r;

    // Prompt the user to input the amount given and the bill amount.
    scanf("%d", &amtgiven);
    scanf("%d", &billamt);

    // Calculate the quotient and remainder.
    q = amtgiven / billamt;  // Divide amount given by bill amount to get quotient.
    r = amtgiven % billamt;  // Use the remainder operator to get the remainder.

    // Display the result.
    printf("Quotient:%d\nRemainder:%d", q, r);

    // Indicate successful completion of the program.
    return 0;
}

Post a Comment

0 Comments