/*PROGRAM TO ACCEPT TWO NUMBERS FROM THE USER AND PRINT THEIR MULTIPLICATION. */
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c; // Declaration of Variables. Variables 'a' & 'b' to hold first & second number. And 'c' to hold result.
clrscr(); // To clear the output screen every time program is executed.
printf("\n Enter the first number : ");
scanf("%d", &a); // To accept the first number.
printf("\n Enter the second number : ");
scanf("%d", &b); // To accept the second number.
c = a*b; // Logic to get the product of the entered two numbers.
printf("\n Multiplication of %d & %d = %d", a, b, c); // Displaying result.
getch(); // To hold the output screen.
}
Use the following function: int gcd (int a, int b) { while (b != 0) { a %= b; a ^= b ^= a ^= b; } return a; } Note that a ^= b ^= a ^= b is an efficient method of swapping two values.
for two positive integers: public static int gcd(int i1, int i2) { // using Euclid's algorithm int a=i1, b=i2, temp; while (b!=0) { temp=b; b=a%temp; a=temp; } return a; }
To calculate the least common multiple (lcm) of decimals (integers) and fractions you first need to calculate the greatest common divisor (gcd) of two integers: int gcd (int a, int b) { int c; while (a != 0) { c = a; a = b % a; b = c; } return b; } With this function in place, we can calculate the lcm of two integers: int lcm (int a, int b) { return a / gcd (a, b) * b; } And with this function in place we can calculate the lcm of two fractions (a/b and c/d): int lcm_fraction (int a, int b, int c, int d) { return lcm (a, c) / gcd (b, d); }
#include<stdio.h> #include<conio.h> void main() { int a,b,multi; clrscr(); printf("enter a value for a and b"); scanf("%d%d",&a,&b); multi=a*b; printf("the result is %d", multi); getch() }
You can swap two integers without temporary storage by bitwise exclusive-or'ing them in a specific sequence...a ^= b;b ^= a;a ^= b;
Addition is not distrbutive over multiplication. In general,a + (b*c) ≠(a+b)*(a+c) [unless a+b+c = 1]
The four possible combinations are:A = (+, +)B = (+, -)C = (-, +) andD = (-, -)In A and D, the two numbers have the same signs and the multiplication gives a positive answer.In B and C, the two numbers have different signs and the multiplication gives a negative answer.
a*b = exp (ln a + ln b)
Then they are, simply, two different integers. Any two positive integers will do, according to the specification.Then they are, simply, two different integers. Any two positive integers will do, according to the specification.Then they are, simply, two different integers. Any two positive integers will do, according to the specification.Then they are, simply, two different integers. Any two positive integers will do, according to the specification.
The two integers are A and A+40 or, equivalently, B and B-40.
Yes. If you have two positive integers "a" and "b", and their corresponding cubes "a^3" and "b^3" (using "^" for "power"), then the product of the two cubes would be a^3 times b^3 = (ab)^3. Since the product of "a" and "b" is also an integer, you have the cube of an integer.
Because a is rational, there exist integers m and n such that a=m/n. Because b is rational, there exist integers p and q such that b=p/q. Consider a+b. a+b=(m/n)+(p/q)=(mq/nq)+(pn/mq)=(mq+pn)/(nq). (mq+pn) is an integer because the product of two integers is an integer, and the sum of two integers is an integer. nq is an integer since the product of two integers is an integer. Because a+b equals the quotient of two integers, a+b is rational.
Two integers A and B are graphed on a number line. If A is less than B is A always less than B?
Use the following function: int gcd (int a, int b) { while (b != 0) { a %= b; a ^= b ^= a ^= b; } return a; } Note that a ^= b ^= a ^= b is an efficient method of swapping two values.
A number that can be written in the form a/b whre a and b are integers is called a rational number.
The commutative property refers to a fundamental property of certain operations in mathematics, specifically addition and multiplication. It states that the order in which two numbers are combined does not affect the result; for example, (a + b = b + a) for addition, and (a \times b = b \times a) for multiplication. This property holds true for real numbers, integers, and many other mathematical structures. However, it does not apply to operations like subtraction or division.
Subtraction means addition of the additive inverse. For two numbers a and b, we say a-b when we mean a + (-b) where -b is a number with the property that b + -b = 0. This applies to all real numbers, which of course includes integers.