answersLogoWhite

0

#include<stdio.h>

int main(){

int n1,n2;

printf("\nEnter two numbers:");

scanf("%d %d",&n1,&n2);

while(n1!=n2){

if(n1>=n2-1)

n1=n1-n2;

else

n2=n2-n1;

}

printf("\nGCD=%d",n1);

return 0;

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you sum a number's all digit using for loop?

Using for loop we can find sum of digits of a number. Inside the loop just perform Logic Expression 1) rem=num%10. {To find the unit place no. using remainder functon} 2) sum = sum+rem {to find the addition ie output} 3) num=num/10 {to eliminate the added digit} Just repeat these steps in the loop.


What is the time complexity of using a while loop inside a for loop?

The time complexity of using a while loop inside a for loop is O(nm), where n is the number of iterations of the for loop and m is the number of iterations of the while loop.


What is a C programming to calculate the sum of 1-2-3-4-5 and so on using while loop a for loop and a do while loop?

#include using std::cout;using std::endl;int main(){int number(1);cout number;//using loop forint sum(0);for(int i(1); i


To find biggest of four numbers using if else loop?

largest number a,b,c,d


Find factorial at given number using do while loop?

Actually, a for loop is more appropriate in this case. With while, it would be something like the following pseudocode - adapt to your favorite programming language:function factorial(n)result = 1factor = 1while factor


C program find magic number less than 1000?

#define int main (void){/*Algorithm*/1. First Initialize the number that is Random no2. Using while loop if the person got it, then the loop stop if not the loop continues.}return(0);


What is the time complexity of a while loop in a given algorithm?

The time complexity of a while loop in an algorithm is typically represented as O(n), where n is the number of iterations the loop performs.


A loop control variable that is incremented a specific number of times is known as?

A loop control variable is widly known as a "counter".


C program to find square of number using do while loop?

class Abc { public static void main(String[] args) { System.out.println("Hello World!"); } }


How do you find the 12th prime number using c?

To keep it simple: Write a main loop that goes through all the numbers, starting with 2, and incrementing one at a time. Determine whether each number is a prime number. If it is, increment a counter. To determine whether each number is a prime number, either use an inner loop, or a separate function. Test divisibility of the number "n" by every number from 2 to n-1. If you find a factor, then it is not a prime number. Note that you can test divisibility by using the "%" operator. For example: if (number % factor == 0) // number is divisible by factor else // it isn't


How do you calculate loop length?

the multiplication of the number of iterations with the number of statements in that loop is equal to loop length.


How can I use the ffmpeg loop feature to create a continuous video loop?

To create a continuous video loop using the ffmpeg loop feature, you can use the &quot;loop&quot; option in the ffmpeg command followed by the number of times you want the video to loop. For example, you can use the command &quot;ffmpeg -streamloop -1 -i input.mp4 output.mp4&quot; to loop the video indefinitely.