Sudhir sharma has Published 1206 Articles

Find x and y satisfying ax + by = n in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:36:35

507 Views

In this problem, we are given three integer values a, b, and n. Our task is to find x and y satisfying ax + by = n.Let's take an example to understand the problemInput : a = 4, b = 1, n = 5 Output : x = 1, y ... Read More

fopen() for existing file in write mode in C

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:35:23

1K+ Views

fopen() method in C is used to open the specified file.Let’s take an example to understand the problemSyntaxFILE *fopen(filename, mode)The following are valid modes of opening a file using fopen(): ‘r’, ‘w’, ‘a’, ‘r+’, ‘w+’, ‘a+’. For details visit visit C library function - fopen()fopen() for an existing file in ... Read More

Find whether an array is subset of another array - Added Method 3 in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:28:58

258 Views

In this problem, we are given two arrays of integers arr1[] and arr2[] of size m and n. Our task is to find whether an array is subset of another array - Added Method 3.Both arrays arr1[] and arr2[] are unorders and have distinct elements.Let's take an example to understand ... Read More

Find whether a subarray is in form of a mountain or not in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:13:26

103 Views

In this problem, we are given an array of integers arr[] and an range. Our task is to find whether a subarray is in the form of a mountain or not.Let's take an example to understand the problem, Input : arr[] = {1, 4, 2, 5, 6, 7, 3, 0}, ... Read More

Game of Nim with removal of one stone allowed in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:10:55

162 Views

In this problem called the game of Nim, we are given a positive integer N denoting the pile of stones and there are two players ‘playerA’ and ‘playerB’. Our task is to create a program to predict the winner of the Game of Nim.GAME OF NIM − We have a ... Read More

Find whether a given number is a power of 4 or not in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:09:16

575 Views

In this problem, we are given an integer N. Our task is to find whether a given integer is a power of 4 or not.Let's take an example to understand the problem, Input : N = 64 Output : YesExplanation −43 = 64 Solution ApproachA simple solution to the problem ... Read More

For Versus While in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:04:05

136 Views

Loops in programming are used to compute a block of code multiple times. Here we will be seeing the difference between two types of loops in the program, For Loop and While Loop.For LoopFor Loop is a type of repetition control loop which allows the user to loop over the ... Read More

Find whether a given integer is a power of 3 or not in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:04:05

604 Views

In this problem, we are given an integer N. Our task is to find whether a given integer is a power of 3 or not.Let's take an example to understand the problem, Input : N = 729 Output : YesExplanation −36 = 719 Solution ApproachA solution to the problem is ... Read More

Find value of y mod (2 raised to power x) in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 08:00:18

126 Views

In this problem, we are given two values x and y. Our task is to find value of y mod (2 raised to power x).Let's take an example to understand the problem, Input : x = 2, y = 19 Output : 3Explanation −y % 2x = 19 % 22 ... Read More

Find value of k-th bit in binary representation in C++

sudhir sharma

sudhir sharma

Updated on 01-Feb-2022 07:31:06

313 Views

In this problem, we are given two values n and k. Our task is to find value of k-th bit in binary representation.Let's take an example to understand the problem, Input : n= 5, k = 2 Output : 0Explanation −Binary of 5 = 0101 Second LSB bit is 0.Solution ... Read More

Advertisements