54.3k views
2 votes
write a c program that captures two integers from the keyboard and prints the absolute value between the two integers​

2 Answers

3 votes

CODE

#include <stdio.h>

#include <stdlib.h>

int main() {

// Declare the variables

int a, b;

// The user enters two integers

printf("Enter the first integer: ");

scanf("%d",&a);

printf("Enter the second integer: ");

scanf("%d",&b);

// Display the absolute values

printf("The absolute values of the integers are %d and %d.\\",abs(a),abs(b));

printf("The absolute value of the difference between the integers is %d.\\",abs(a-b));

return 0;

}

Step-by-step explanation

The header includes stdlib.h to call to abs() function.

Declare the variables a and b as integers.

Ask the users to enter the integers.

Display the absolute values of a and b.

Display the absolute value of a-b.

User DallonF
by
3.9k points
4 votes

console.writeLine("Enter a integer")

int num1 = console.readline();

console.writeline("Enter another integer")

int num2 = console.readline();

int difference = num1 - num2;

console.Writeline("The difference between the numbers is"+difference)

If you copy paste this, you will get an error, type it in line by line

User Bavan
by
3.6k points