Professional Documents
Culture Documents
: 01
Student Name : Aman sehgal UID : 20BCS5252
Branch : BE CSE Section/Group : 612/A
Semester : 5 Date of Performance : 02/08/2022
Subject Name : Design and Analysis of Algorithms Lab
Subject Code : 20CSP-312
Code and analyse to compute the greatest common divisor (GCD) of two numbers .
#include <iostream>
using namespace std;
int main() {
int n1, n2, hcf; cout << "Enter two
numbers: " << endl; cin >> n1 >> n2;
if ( n2 > n1) {
int temp = n2;
n2 = n1;
n1 =
temp; } for
(int i = 1; i
<= n2; ++i)
{ if (n1 % i
== 0 &&
n2 % i
==0) {
hcf = i;
} } cout << "HCF =
" << hcf;
return 0;
}
3. Result/Output/Writing Summary:
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
Sr. No. Parameters Marks Obtained Maximum Marks
1.
2.
3.