Answer:
This program is written using Java programming language
import java.util.*;
public class calcGcd
{
public static void main (String [] args)
{
int num1, num2;
Scanner input = new Scanner(System.in);
//Input two integers
num1 = input.nextInt();
num2 = input.nextInt();
//Get least of the two integers
int least = num1;
if(num1 > num2)
{
least = num2;
}
//Initialize gcd to 1
int gcd = 1;
//Calculate gcd using for loop
for(int i=1;i<=least;i++)
{
if(num1%i == 0 && num2%i == 0)
{
gcd = i;
}
}
if(gcd == 1)
{
System.out.print("GCD is 1");
}
else
{
System.out.print("GCD is "+gcd);
}
}
}
Explanation:
To calculate the GCD, the program uses a for loop that iterates from 1 to the smaller number of the user input.
Within this iteration, the program checks for a common divisor of the two user inputs by the iterating element
The GCD is then displayed afterwards;
However, if the GCD is 1; the program prints the message "GCD is 1"
Line by Line Explanation
This line declares two integer numbers
int num1, num2;
This line allows user the program to accept user defined inputs
Scanner input = new Scanner(System.in);
The next two line allows gets inputs from the user
num1 = input.nextInt();
num2 = input.nextInt();
To calculate the GCD, the smaller of the two numbers is needed. The smaller number is derived using the following if statement
int least = num1;
if(num1 > num2)
{
least = num2;
}
The next line initializes GCD to 1
int gcd = 1;
The GCD is calculated using the following for loop
The GCD is the highest number that can divide both numbers
for(int i=1;i<=least;i++)
{
if(num1%i == 0 && num2%i == 0)
{
gcd = i;
}
}
The following is printed if the calculated GCD is 1
if(gcd == 1)
{
System.out.print("GCD is 1");
}
Otherwise, the following is printed
else
{
System.out.print("GCD is "+gcd);
}
what does the U in fun stand for?
Answer:
You and me
Explanation:
F is for friend and N is for anytime and anywhere
Martha is developing a software program in C++ and has a question about how to implement a particular feature. She performs an online search and finds a link to a site written by a programmer with posts about tips and tricks in using the C++ language. What kind of resource did she find? a forum a blog a tutorial an online help site
Answer:
A blog
Explanation:
A blog is a regularly updated website or web page, typically one run by an individual or small group, that is organised by posts.
Answer:
Martha found a blog
Trace en su cuaderno una hoja de cálculo de A1 a D15, escriba en cada celda un valor entre 100.000 y 500.000, luego escriba las fórmulas para hallar halle los siguientes valores: Sumar celdas columna B Restar celdas A12 menos D3 Multiplique Celdas columna C por celdas columna D Divida las celdas A11 hasta A15 entre celdas D11 a D15
Answer:
Vincent is a digital media professional. His bosses always praise his artwork. His company has just taken on a new project. Vincent has some thoughts and ideas about this new project that he wants to discuss with the senior employees. What kind of skills should he use to pitch his ideas?
Explanation i had this on a quiz and past
Write the program code to find the cube of numbers from 1-5. Also do the dry run by using the trace table. (Javascript)
Answer:
Following are the JavaScript program
< html >
< body >
< script >
var k,t; // variable declaration
for (k = 1; i < 6; k++) // iterating the loop
{
t=k*k*k;// find the cube of number
document.write(k); // display the cube root
document.write(" < / br > " ); // moves to the next line
}
< / script >
< / body >
< / html >
Output:
1
8
27
64
125
Explanation:
We used the script tag for creating the JavaScript program. Declared the variable "k" in the script tag.Iterating the for loop .In the for loop the k variable is initialized by the 1 This loop is executed less then 6 .In each iteration we find the cube of number in the "t" variable and display that number by using document .write ().