From c5d55d0d3d154403a2e923c959d9aff037b30679 Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Tue, 27 Jan 2026 17:58:10 +0530 Subject: [PATCH 01/19] Create ManjariNK_sumofnaturalnumbers_q1.cpp --- ManjariNK_sumofnaturalnumbers_q1.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ManjariNK_sumofnaturalnumbers_q1.cpp diff --git a/ManjariNK_sumofnaturalnumbers_q1.cpp b/ManjariNK_sumofnaturalnumbers_q1.cpp new file mode 100644 index 0000000..58b584e --- /dev/null +++ b/ManjariNK_sumofnaturalnumbers_q1.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; +int main() +{ + int num; + int sum=0; + cin>>num; + for(int i=1;i<=num;i++) + { + sum+=i; + } + cout< Date: Tue, 27 Jan 2026 17:59:21 +0530 Subject: [PATCH 02/19] Create ManjariNK_positiveornegative_q2.cpp --- ManjariNK_positiveornegative_q2.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ManjariNK_positiveornegative_q2.cpp diff --git a/ManjariNK_positiveornegative_q2.cpp b/ManjariNK_positiveornegative_q2.cpp new file mode 100644 index 0000000..4a8414b --- /dev/null +++ b/ManjariNK_positiveornegative_q2.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; +int main(){ + int number; + cin>>number; + if(number>0) + { + cout<<"The number is Positive"; + } + else if(number<0) + { + cout<<"The number is Negative"; + } + else{ + cout<<"The number is Zero"; + } +} From 6e6f2ecfadf91671eaf6502d74bbfd2fa76ffef0 Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Wed, 28 Jan 2026 23:19:18 +0530 Subject: [PATCH 03/19] Create manjariNK_Greatest_of_two_numbers_q3.cpp --- manjariNK_Greatest_of_two_numbers_q3.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 manjariNK_Greatest_of_two_numbers_q3.cpp diff --git a/manjariNK_Greatest_of_two_numbers_q3.cpp b/manjariNK_Greatest_of_two_numbers_q3.cpp new file mode 100644 index 0000000..8bdd2cb --- /dev/null +++ b/manjariNK_Greatest_of_two_numbers_q3.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; +int main() +{ + int num1; + int num2; + cin>>num1>>num2; + if(num1==num2) + { + cout<<"Both are equal"; + }else{ + num1>num2 ? cout< Date: Wed, 28 Jan 2026 23:21:10 +0530 Subject: [PATCH 04/19] Create ManjariNK_even_or_odd_q4.cpp --- ManjariNK_even_or_odd_q4.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 ManjariNK_even_or_odd_q4.cpp diff --git a/ManjariNK_even_or_odd_q4.cpp b/ManjariNK_even_or_odd_q4.cpp new file mode 100644 index 0000000..b40df3c --- /dev/null +++ b/ManjariNK_even_or_odd_q4.cpp @@ -0,0 +1,9 @@ +#include +using namespace std; +int main() +{ + int num; + cin>>num; + num%2==0 ? cout<<"Even":cout<<"Odd"; + return 0; +} From 5104d0b77d4532a0aadeaa7df4dd2da1ffd6df9a Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Wed, 28 Jan 2026 23:22:21 +0530 Subject: [PATCH 05/19] Create ManjariNK_sum_of_naturalNumbers_inRange_q5.cpp --- ManjariNK_sum_of_naturalNumbers_inRange_q5.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ManjariNK_sum_of_naturalNumbers_inRange_q5.cpp diff --git a/ManjariNK_sum_of_naturalNumbers_inRange_q5.cpp b/ManjariNK_sum_of_naturalNumbers_inRange_q5.cpp new file mode 100644 index 0000000..e6f9641 --- /dev/null +++ b/ManjariNK_sum_of_naturalNumbers_inRange_q5.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; +int main() +{ + int num1; + int num2; + cin>>num1>>num2; + int sum=0; + for(int i=num1;i Date: Thu, 29 Jan 2026 22:10:08 +0530 Subject: [PATCH 06/19] Create Manjari_leapyear_q6.cpp --- Manjari_leapyear_q6.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Manjari_leapyear_q6.cpp diff --git a/Manjari_leapyear_q6.cpp b/Manjari_leapyear_q6.cpp new file mode 100644 index 0000000..d911032 --- /dev/null +++ b/Manjari_leapyear_q6.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; +int main() +{ + int year; + cin>>year; + if((year%4==0 && year%100!=0) || (year%400==0)) + { + cout< Date: Fri, 30 Jan 2026 23:18:57 +0530 Subject: [PATCH 07/19] Create ManjariNK_sumofdigits_q7.cpp --- ManjariNK_sumofdigits_q7.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 ManjariNK_sumofdigits_q7.cpp diff --git a/ManjariNK_sumofdigits_q7.cpp b/ManjariNK_sumofdigits_q7.cpp new file mode 100644 index 0000000..5854e50 --- /dev/null +++ b/ManjariNK_sumofdigits_q7.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + +int main() +{ + int num; + cin>>num; + int temp=num,sum=0; + while(temp!=0) + { + sum+=temp%10; + temp/=10; + } + cout< Date: Sat, 31 Jan 2026 23:37:00 +0530 Subject: [PATCH 08/19] Create power_of_number_q8.cpp --- power_of_number_q8.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 power_of_number_q8.cpp diff --git a/power_of_number_q8.cpp b/power_of_number_q8.cpp new file mode 100644 index 0000000..851c676 --- /dev/null +++ b/power_of_number_q8.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; +int main() +{ + int base, expo; + cin>>base>>expo; + int res=1; + for(int i=1;i<=expo;i++) + { + res*=base; + } + cout< Date: Wed, 25 Mar 2026 22:08:46 +0530 Subject: [PATCH 09/19] Add files via upload --- prime_number_with_in range.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prime_number_with_in range.cpp diff --git a/prime_number_with_in range.cpp b/prime_number_with_in range.cpp new file mode 100644 index 0000000..e69de29 From 49ea979e01e1db41bb07e980f7f65cc54576ce02 Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Wed, 25 Mar 2026 22:10:19 +0530 Subject: [PATCH 10/19] Delete prime_number_with_in range.cpp --- prime_number_with_in range.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 prime_number_with_in range.cpp diff --git a/prime_number_with_in range.cpp b/prime_number_with_in range.cpp deleted file mode 100644 index e69de29..0000000 From c6ef33989999ca4e5524d1f47481bbec31f9b70d Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Wed, 25 Mar 2026 22:10:40 +0530 Subject: [PATCH 11/19] Add files via upload --- prime_number_with_in range.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 prime_number_with_in range.cpp diff --git a/prime_number_with_in range.cpp b/prime_number_with_in range.cpp new file mode 100644 index 0000000..61c3ab0 --- /dev/null +++ b/prime_number_with_in range.cpp @@ -0,0 +1,27 @@ +#include +#include +using namespace std; + +bool isPrime(int n) { + if (n <= 1) return false; + + for (int i = 2; i <= sqrt(n); i++) { + if (n % i == 0) { + return false; + } + } + return true; +} + +int main() { + int range; + cin >> range; + + for(int i =0 ;i Date: Thu, 26 Mar 2026 01:02:10 +0530 Subject: [PATCH 12/19] Rename prime_number_with_in range.cpp to prime_number_with_in range_q9.cpp --- ...umber_with_in range.cpp => prime_number_with_in range_q9.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename prime_number_with_in range.cpp => prime_number_with_in range_q9.cpp (99%) diff --git a/prime_number_with_in range.cpp b/prime_number_with_in range_q9.cpp similarity index 99% rename from prime_number_with_in range.cpp rename to prime_number_with_in range_q9.cpp index 61c3ab0..73c0994 100644 --- a/prime_number_with_in range.cpp +++ b/prime_number_with_in range_q9.cpp @@ -24,4 +24,4 @@ int main() { } return 0; -} \ No newline at end of file +} From 98f5b0febc1a834f4208c6f23b4708a339bf9677 Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Thu, 26 Mar 2026 01:05:19 +0530 Subject: [PATCH 13/19] Add files via upload --- armstrong.cpp | 33 ++++++++++++++++++++++++++++ armstrong_in_give_range.cpp | 44 +++++++++++++++++++++++++++++++++++++ palindrome_or_not.cpp | 20 +++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 armstrong.cpp create mode 100644 armstrong_in_give_range.cpp create mode 100644 palindrome_or_not.cpp diff --git a/armstrong.cpp b/armstrong.cpp new file mode 100644 index 0000000..6e600bd --- /dev/null +++ b/armstrong.cpp @@ -0,0 +1,33 @@ +#include +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int temp = n; + int c =0; + if (n < 0) { + cout << "Its not an armstrong number"; + return 0; + } + while(temp!=0) + { + temp /= 10; + c++; + } + if (n == 0) c = 1; + temp=n; + int a=0; + while(temp!=0) + { + int k = temp%10; + a=a+pow(k,c); + temp /=10; + } + if(a==n){ + cout<<"Its a armstrong number"; + }else{ + cout<<"its not an armstrong number"; + } +} \ No newline at end of file diff --git a/armstrong_in_give_range.cpp b/armstrong_in_give_range.cpp new file mode 100644 index 0000000..cf977ff --- /dev/null +++ b/armstrong_in_give_range.cpp @@ -0,0 +1,44 @@ +#include +#include +using namespace std; +bool armstrong(int n) +{ + int temp = n; + int c=0; + if (n < 0) { + return false; + } + while(temp!=0) + { + temp /= 10; + c++; + } + if (n == 0) c = 1; + temp=n; + int a=0; + while(temp!=0) + { + int k = temp%10; + a=a+(int)pow(k,c); + temp /=10; + } + if(a==n){ + return true; + }else{ + return false; + } +} +int main() +{ + int n , m; + cin>>n>>m; + for(int i=n;i +using namespace std; +int main() +{ + int n; + cin>>n; + int temp = n; + int rev =0; + while(temp!=0) + { + rev = rev*10 + temp%10; + temp=temp/10; + } + if(n==rev) + { + cout<<"Its a palindrome"; + }else{ + cout<<"Its not a palindrome"; + } +} \ No newline at end of file From 424b7d2d7b895727b0daddbe32d6aa746fe9f6c7 Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Thu, 26 Mar 2026 01:06:11 +0530 Subject: [PATCH 14/19] Rename palindrome_or_not.cpp to palindrome_or_not_q10.cpp --- palindrome_or_not.cpp => palindrome_or_not_q10.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename palindrome_or_not.cpp => palindrome_or_not_q10.cpp (99%) diff --git a/palindrome_or_not.cpp b/palindrome_or_not_q10.cpp similarity index 99% rename from palindrome_or_not.cpp rename to palindrome_or_not_q10.cpp index 63f437f..295d254 100644 --- a/palindrome_or_not.cpp +++ b/palindrome_or_not_q10.cpp @@ -17,4 +17,4 @@ int main() }else{ cout<<"Its not a palindrome"; } -} \ No newline at end of file +} From 120a53bbfa1ba8b6d653d890f198b4b2933ef9b3 Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Thu, 26 Mar 2026 01:06:33 +0530 Subject: [PATCH 15/19] Rename armstrong_in_give_range.cpp to armstrong_in_give_range_q11.cpp --- armstrong_in_give_range.cpp => armstrong_in_give_range_q11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename armstrong_in_give_range.cpp => armstrong_in_give_range_q11.cpp (99%) diff --git a/armstrong_in_give_range.cpp b/armstrong_in_give_range_q11.cpp similarity index 99% rename from armstrong_in_give_range.cpp rename to armstrong_in_give_range_q11.cpp index cf977ff..27d5f0c 100644 --- a/armstrong_in_give_range.cpp +++ b/armstrong_in_give_range_q11.cpp @@ -41,4 +41,4 @@ int main() } -} \ No newline at end of file +} From 823f3092f742f699b20cccef7ccc65694c7e0254 Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Thu, 26 Mar 2026 01:06:54 +0530 Subject: [PATCH 16/19] Rename armstrong.cpp to armstrong_q12.cpp --- armstrong.cpp => armstrong_q12.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename armstrong.cpp => armstrong_q12.cpp (99%) diff --git a/armstrong.cpp b/armstrong_q12.cpp similarity index 99% rename from armstrong.cpp rename to armstrong_q12.cpp index 6e600bd..46a3b28 100644 --- a/armstrong.cpp +++ b/armstrong_q12.cpp @@ -30,4 +30,4 @@ int main() }else{ cout<<"its not an armstrong number"; } -} \ No newline at end of file +} From f62fffb3555d05cf533feec4ac4ec4b6ef096992 Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Thu, 26 Mar 2026 01:37:58 +0530 Subject: [PATCH 17/19] Add files via upload --- Factorial_of_a_Number_q15.cpp | 15 +++++++++++++++ Nth_Term_of_the_Fibonacci_Series_q14.cpp | 18 ++++++++++++++++++ fibonacci_q13.cpp | 18 ++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 Factorial_of_a_Number_q15.cpp create mode 100644 Nth_Term_of_the_Fibonacci_Series_q14.cpp create mode 100644 fibonacci_q13.cpp diff --git a/Factorial_of_a_Number_q15.cpp b/Factorial_of_a_Number_q15.cpp new file mode 100644 index 0000000..1ca762e --- /dev/null +++ b/Factorial_of_a_Number_q15.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; +int fact(int n) +{ + if(n<=1) + return 1; + return n * fact(n-1); +} +int main() +{ + int n; + cin >> n; + cout< +using namespace std; + +int main() +{ + int n; + cin >> n; + + int a = 0, b = 1; + + for(int i = 1; i < n; i++) + { + int next = a + b; + a = b; + b = next; + } + cout << a << " "; +} \ No newline at end of file diff --git a/fibonacci_q13.cpp b/fibonacci_q13.cpp new file mode 100644 index 0000000..fdb23ac --- /dev/null +++ b/fibonacci_q13.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; + +int main() +{ + int n; + cin >> n; + + int a = 0, b = 1; + + for(int i = 1; i <= n; i++) + { + cout << a << " "; + int next = a + b; + a = b; + b = next; + } +} \ No newline at end of file From 3169e220b06761b5d3ef1f87b2aec09abb6f9b3c Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Thu, 26 Mar 2026 15:46:20 +0530 Subject: [PATCH 18/19] Add files via upload --- Abundant_number_q23.cpp | 22 ++++++++++++++++++++++ Automorphic_number_q21.cpp | 23 +++++++++++++++++++++++ Harshad_number_q22.cpp | 21 +++++++++++++++++++++ factor_q16.cpp | 14 ++++++++++++++ friendly_pairs_q24.cpp | 29 +++++++++++++++++++++++++++++ hcf_q25.cpp | 18 ++++++++++++++++++ perfect_number_q19.cpp | 21 +++++++++++++++++++++ perfect_square_q20.cpp | 15 +++++++++++++++ prime_factor_q17.cpp | 26 ++++++++++++++++++++++++++ strong_number_q18.cpp | 27 +++++++++++++++++++++++++++ 10 files changed, 216 insertions(+) create mode 100644 Abundant_number_q23.cpp create mode 100644 Automorphic_number_q21.cpp create mode 100644 Harshad_number_q22.cpp create mode 100644 factor_q16.cpp create mode 100644 friendly_pairs_q24.cpp create mode 100644 hcf_q25.cpp create mode 100644 perfect_number_q19.cpp create mode 100644 perfect_square_q20.cpp create mode 100644 prime_factor_q17.cpp create mode 100644 strong_number_q18.cpp diff --git a/Abundant_number_q23.cpp b/Abundant_number_q23.cpp new file mode 100644 index 0000000..f2255fd --- /dev/null +++ b/Abundant_number_q23.cpp @@ -0,0 +1,22 @@ +#include +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int sum = 0 ; + for(int i = 1;in) + { + cout<<"Its a Abundant number"; + }else{ + cout<<"its not a Abundant number"; + } +} \ No newline at end of file diff --git a/Automorphic_number_q21.cpp b/Automorphic_number_q21.cpp new file mode 100644 index 0000000..848658f --- /dev/null +++ b/Automorphic_number_q21.cpp @@ -0,0 +1,23 @@ +#include +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int s = n*n; + int temp = n; + int c = 0; + while(temp !=0) + { + temp /= 10; + c++; + } + int k = s % (int)pow(10,c); + if(k == n) + { + cout<<"its a Automorphic number"; + }else{ + cout<<"its not a Automorphic number"; + } +} \ No newline at end of file diff --git a/Harshad_number_q22.cpp b/Harshad_number_q22.cpp new file mode 100644 index 0000000..2159d24 --- /dev/null +++ b/Harshad_number_q22.cpp @@ -0,0 +1,21 @@ +#include +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int temp = n; + int c = 0; + while(temp !=0) + { + c +=temp%10; + temp /= 10; + } + if(n%c ==0) + { + cout<<"its a Harshad number"; + }else{ + cout<<"its not a Harshad number"; + } +} \ No newline at end of file diff --git a/factor_q16.cpp b/factor_q16.cpp new file mode 100644 index 0000000..b741a95 --- /dev/null +++ b/factor_q16.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; +int main(){ + int n; + cin>>n; + for(int i=1;i<=n/2;i++) + { + if(n%i==0) + { + cout< +#include +using namespace std; +int main() +{ + int n,m; + cin>>n>>m; + int sum = 0 , s=0 ; + for(int i = 1;i +#include +using namespace std; +int main() +{ + int n,m; + cin>>n>>m; + int hcf = 1; + for(int i = 1; i <= n || i <= m; i++) + { + if(n % i == 0 && m % i == 0) + hcf = i; + } + + cout<<"HCF of "< +using namespace std; +int main() +{ + int n; + cin>>n; + int sum=0; + for(int i=1;i<=n/2;i++) + { + if(n%i==0) + { + sum+=i; + } + } + if(sum==n) + { + cout<<"its a perfect number"; + }else{ + cout<<"Its not a perfect number"; + } +} \ No newline at end of file diff --git a/perfect_square_q20.cpp b/perfect_square_q20.cpp new file mode 100644 index 0000000..0d6d38d --- /dev/null +++ b/perfect_square_q20.cpp @@ -0,0 +1,15 @@ +#include +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int r = sqrt(n) ; + if(r * r ==n ) + { + cout<<"its a perfect square"; + }else{ + cout<<"its not a perfect square"; + } +} \ No newline at end of file diff --git a/prime_factor_q17.cpp b/prime_factor_q17.cpp new file mode 100644 index 0000000..775cb7e --- /dev/null +++ b/prime_factor_q17.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; +bool prime(int n) +{ + if (n <= 1) return false; + + for (int i = 2; i * i <= n; i++) { + if (n % i == 0) + return false; + } + return true; +} +int main(){ + int n; + cin>>n; + for(int i=1;i<=n;i++) + { + if(n%i==0) + { + if(prime(i)) + { + cout< +using namespace std; +int fact(int k) +{ + if(k<=1) + return 1; + return k * fact(k-1); +} +int main() +{ + int n; + cin>>n; + int temp = n; + int sum=0; + while(temp != 0) + { + int k = temp%10; + sum +=fact(k); + temp /=10; + } + if(sum==n) + { + cout<<"Its a strong number"; + }else{ + cout<<"Its not a strong number"; + } +} \ No newline at end of file From 814a23b48658f55830d56a4503484a4dbbad682b Mon Sep 17 00:00:00 2001 From: Manjari N K <181546610+Manjarink@users.noreply.github.com> Date: Mon, 30 Mar 2026 20:20:05 +0530 Subject: [PATCH 19/19] Add files via upload --- add_2fractions_q37.cpp | 21 ++++++++++++++++++++ binary_to_decimal_q28.cpp | 17 ++++++++++++++++ coordinate_lies_q34.cpp | 23 ++++++++++++++++++++++ decimal_to_binary_q31.cpp | 17 ++++++++++++++++ decimal_to_hexadecimal_q33.cpp | 22 +++++++++++++++++++++ decimal_to_octacl_q32.cpp | 17 ++++++++++++++++ gcd_q27.cpp | 13 +++++++++++++ handshake_exactly_once_q36.cpp | 9 +++++++++ hexadecimal_to_decimal_q30.cpp | 26 +++++++++++++++++++++++++ lcm_q26.cpp | 29 ++++++++++++++++++++++++++++ number_of_digits_q40.cpp | 19 ++++++++++++++++++ number_sumof2primenumber_q41.cpp | 33 ++++++++++++++++++++++++++++++++ occurance_q39.cpp | 25 ++++++++++++++++++++++++ octal_to_decimal_q29.cpp | 17 ++++++++++++++++ permutation_q35.cpp | 15 +++++++++++++++ replace0_with1_q38.cpp | 21 ++++++++++++++++++++ 16 files changed, 324 insertions(+) create mode 100644 add_2fractions_q37.cpp create mode 100644 binary_to_decimal_q28.cpp create mode 100644 coordinate_lies_q34.cpp create mode 100644 decimal_to_binary_q31.cpp create mode 100644 decimal_to_hexadecimal_q33.cpp create mode 100644 decimal_to_octacl_q32.cpp create mode 100644 gcd_q27.cpp create mode 100644 handshake_exactly_once_q36.cpp create mode 100644 hexadecimal_to_decimal_q30.cpp create mode 100644 lcm_q26.cpp create mode 100644 number_of_digits_q40.cpp create mode 100644 number_sumof2primenumber_q41.cpp create mode 100644 occurance_q39.cpp create mode 100644 octal_to_decimal_q29.cpp create mode 100644 permutation_q35.cpp create mode 100644 replace0_with1_q38.cpp diff --git a/add_2fractions_q37.cpp b/add_2fractions_q37.cpp new file mode 100644 index 0000000..0a07b63 --- /dev/null +++ b/add_2fractions_q37.cpp @@ -0,0 +1,21 @@ +#include +#include +using namespace std; +int gcd(int a , int b) +{ + if(b==0) + return a; + return gcd(b , a%b); +} +int main() +{ + int a , b, c, d; + cin>>a>>b>>c>>d; + int lcm = b*d/gcd(b,d); + int x ; + x = a*(lcm/b) + c*(lcm/d); + int g =gcd(x , lcm); + x=x/g; + lcm=lcm/g; + cout< +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int temp = n; + int sum =0; + int c=0; + while(temp !=0) + { + sum += (temp%10) * pow(2,c++); + temp /=10; + } + cout< +using namespace std; + +int main() +{ + int x, y; + cin >> x >> y; + + if(x > 0 && y > 0) + cout << "1st Quadrant"; + else if(x < 0 && y > 0) + cout << "2nd Quadrant"; + else if(x < 0 && y < 0) + cout << "3rd Quadrant"; + else if(x > 0 && y < 0) + cout << "4th Quadrant"; + else if(x == 0 && y == 0) + cout << "Origin"; + else if(x == 0) + cout << "Y-axis"; + else + cout << "X-axis"; +} \ No newline at end of file diff --git a/decimal_to_binary_q31.cpp b/decimal_to_binary_q31.cpp new file mode 100644 index 0000000..c208657 --- /dev/null +++ b/decimal_to_binary_q31.cpp @@ -0,0 +1,17 @@ +#include +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int temp =n; + int bi =0; + int c=0; + while(temp!=0) + { + bi=bi+(temp%2)*pow(10,c++); + temp/=2; + } + cout< +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int temp =n; + string bi=""; + while(temp!=0) + { + int k = (temp%16); + if(k>=10) + { + bi= (char)(k+55)+bi; + }else{ + bi=char(k +'0')+bi; + } + temp/=16; + } + cout< +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int temp =n; + int bi =0; + int c=0; + while(temp!=0) + { + bi=bi+(temp%8)*pow(10,c++); + temp/=8; + } + cout< +#include +using namespace std; +int gcd(int n , int m) +{ + return m == 0 ? n : gcd(m , n%m); +} +int main() +{ + int n,m; + cin>>n>>m; + cout< +#include +using namespace std; +int main() +{ + int x; + cin>>x; + cout<<(x*(x-1))/2; +} \ No newline at end of file diff --git a/hexadecimal_to_decimal_q30.cpp b/hexadecimal_to_decimal_q30.cpp new file mode 100644 index 0000000..770dfbb --- /dev/null +++ b/hexadecimal_to_decimal_q30.cpp @@ -0,0 +1,26 @@ +#include +#include +using namespace std; +int main() +{ + string n; + cin>>n; + int base = 16; + int dec=0; + for(int i=n.length()-1 ;i>=0 ;i--) + { + if(n[i]>='0' && n[i]<='9') + { + dec+=(n[i] - '0')*base; + }else if(n[i]>='A' && n[i]<='F') + { + dec+=(n[i] - 'A')*base; + }else if(n[i]>='a' && n[i]<='f') + { + dec+=(n[i] - 'a')*base; + } + base*=16; + } + cout< +using namespace std; + +int gcd(int a, int b) +{ + while(b != 0) + { + int r = a % b; + a = b; + b = r; + } + return a; +} + +int main() +{ + int a, b; + cin >> a >> b; + + if(a == 0 || b == 0) + { + cout << "LCM = 0"; + return 0; + } + + int lcm = (a * b) / gcd(a, b); + + cout << "LCM = " << lcm; +} \ No newline at end of file diff --git a/number_of_digits_q40.cpp b/number_of_digits_q40.cpp new file mode 100644 index 0000000..cf5b5cc --- /dev/null +++ b/number_of_digits_q40.cpp @@ -0,0 +1,19 @@ +#include +#include +using namespace std; +int main() +{ + int x; + cin>>x; + int temp=x; + int c=0; + while(temp!=0) + { + temp/=10; + c++; + } + if(x==0) + cout<<"number of digits = "<<1; + else + cout<<"number of digits = "< +#include +using namespace std; +bool isprime(int n) +{ + if(n<=1) + return false; + for(int i=2;i*i<=n;i++) + { + if(n%i==0) + return false; + } + return true; +} +int main() +{ + int x; + cin>>x; + + for(int i=2;i<=x/2;i++) + { + if(isprime(i) && isprime(x-i)) + { + if(x==i+(x-i)) + { + cout<<" can be represented as sum of two prime numbers"; + return 0; + } + } + + } + cout<<"cant be represented "; +} \ No newline at end of file diff --git a/occurance_q39.cpp b/occurance_q39.cpp new file mode 100644 index 0000000..1338634 --- /dev/null +++ b/occurance_q39.cpp @@ -0,0 +1,25 @@ +#include +#include +using namespace std; +int main() +{ + int x,y; + cin>>x>>y; + int temp=x; + int c=0; + if(y < 0 || y > 9) + { + cout << "Invalid digit"; + return 0; + } + if(x == 0 && y == 0) + count = 1; + while(temp!=0) + { + int k = temp%10; + temp/=10; + if(k==y) + c++; + } + cout< +#include +using namespace std; +int main() +{ + int n; + cin>>n; + int temp = n; + int sum =0; + int c=0; + while(temp !=0) + { + sum += (temp%10) * (int)pow(8,c++); + temp /=10; + } + cout< +#include +using namespace std; +int fact(int n) +{ + if(n<=1) + return 1; + return n *fact(n-1); +} +int main() +{ + int x , y; + cin>>x>>y; + cout< +#include +using namespace std; +int main() +{ + int x; + cin>>x; + int z=0,c=0; + while(x!=0) + { + int k = x%10; + if(k) + { + z=k*(int)pow(10,c++)+z; + }else{ + z=1*(int)pow(10,c++)+z; + } + x/=10; + } + cout<