0% found this document useful (0 votes)
57 views4 pages

#Include #Include Main

The document contains code snippets and explanations for calculating the greatest common divisor (GCD) of two numbers, determining if a year is a leap year, and calculating the sum of integers from 1 to a given number. It provides C code to find the GCD of two numbers using modulo and a for loop. It also includes C code that uses the modulo and if-else conditional statements to check if a year is a leap year. Additionally, it shows C code that uses a for loop to calculate the sum of integers from 1 to a given number entered by the user.

Uploaded by

Makim Bapari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views4 pages

#Include #Include Main

The document contains code snippets and explanations for calculating the greatest common divisor (GCD) of two numbers, determining if a year is a leap year, and calculating the sum of integers from 1 to a given number. It provides C code to find the GCD of two numbers using modulo and a for loop. It also includes C code that uses the modulo and if-else conditional statements to check if a year is a leap year. Additionally, it shows C code that uses a for loop to calculate the sum of integers from 1 to a given number entered by the user.

Uploaded by

Makim Bapari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

গসাগু ফ্যাক্ট

#include <stdio.h>
#include <conio.h>
main()
{
int n1,n2,i,gcd;
printf("Enter two integers: ");
scanf("%d%d",&n1 &n2);
for(i=1;i<=n1;i=i+1)
{
if(n1%i==0&&n2%i==0)
gcd=i;
}
printf("G.C.D is %d",gcd);
lcm=(n1*n2)/gcd;
printf("The LCM is %d",lcm);
}
getch();
}

GCD=greatest common divisor 14, 21 gcd=??


14’s divisor=1,2,7,14
21’s divisor = 1,3,7,21
Common divisor= 1,7
greatest common divisor=7
i=iteration/ loop (for loop)

18’s divisor=1,2,3,6,9
24’s divisor = 1,2,3,4,6,12,24
Common divisor= 1,2,3,6
greatest common divisor= 6
1+2+3+………….+100
for(i=1;i<=100,i=i+1)
লসাগু=(১ম*২য়)/গসাগু
=(৬*১২)/৬
=১২

2+4+6+………….+2000
for(i=2;i<=2000,i=i+2)

5+10+15+………….+N
for(i=5;i<=N;i=i+5)

1+3+5+………….+N
2+4+6+………….+N
14=n1
21 =n2
N1%i==0&&n2%i==0

i=1,2,3,4,5,6,7,8,9,10,11,12,13,14
for(i=1; i<=n1; i=i+1)
i=gcd;
Lcm =least common multiple

লসাগু

#include <stdio.h>
int main() {
int n1, n2, i, gcd, lcm;
printf("Enter two positive integers: ");
scanf("%d %d", &n1, &n2);

for (i = 1; i <= n1 && i <= n2; ++i) {

// check if i is a factor of both integers


if (n1 % i == 0 && n2 % i == 0)
gcd = i;
}

lcm = (n1 * n2) / gcd;

printf("The LCM of two numbers %d and %d is %d.", n1, n2, lcm);


return 0;
}

#include <stdio.h>

int main() {
int year;
year = 2016;

if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))


printf("%d is a leap year", year);
else
printf("%d is not a leap year", year);

return 0;
}
লিপ ইয়ার কি না
ধারার যোগফল

#include <stdio.h>
int main() {
int n, i, sum = 0;

printf("Enter a positive integer: ");


scanf("%d", &n);

for (i = 1; i <= n; ++i) {


sum += i;
}

printf("Sum = %d", sum);


return 0;
}

You might also like