Sunidhi Bansal

Sunidhi Bansal

809 Articles Published

Articles by Sunidhi Bansal

Page 51 of 81

Program for K Most Recently Used (MRU) Apps in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 2K+ Views

Given a number k and an array arr[n], containing n number of integer elements which are storing the id’s of the opened apps in a system; the task is to show k number of most recently used apps, like when we press alt+tab shows all the recent apps and most recent before the least recent. The position of every id represents different apps in a system −They are as follows −Id in arr[0] is the id of an app which is currently in use.Id in arr[1] is the id of an app which was most recently used.Id in arr[n-1] is ...

Read More

Program for power of a complex number in O(log n) in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 2K+ Views

Given a complex number in the form of x+yi and an integer n; the task is calculate and print the value of the complex number if we power the complex number by n.What is a complex number?A complex number is number which can be written in the form of a + bi, where a and b are the real numbers and i is the solution of the equation or we can say an imaginary number. So, simply putting it we can say that complex number is a combination of Real number and imaginary number.Raising power of a complex numberTo raise ...

Read More

C Program for Muller Method

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 1K+ Views

We are given with a function f(x) on a floating number x and we can have three initial guesses for the root of the function. The task is to find the root of the function where f(x) can be any algebraic or transcendental function.What is Muller Method?Muller method was first presented by David E. Muller in 1956. A Muller’s method is root finding algorithm which starts with three initial approximations to find the root and then join them with a second degree polynomial (a parabola), then the quadratic formula is used to find a root of the quadratic for the ...

Read More

Problem with scanf() when there is fgets()/gets()/scanf() after it in C

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 612 Views

The problem states that what will be the working or the output if the scanf is followed by fgets()/gets()/scanf().fgets()/gets() followed by scanf()Example#include int main() {    int x;    char str[100];    scanf("%d", &x);    fgets(str, 100, stdin);    printf("x = %d, str = %s", x, str);    return 0; }OutputInput: 30 String Output: x = 30, str =Explanationfgets() and gets() are used to take string input from the user at the run time. I above code when we run enter the integer value then it won’t take the string value because when we gave newline after the integer value, ...

Read More

isprint() Working with C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 428 Views

Isprint() in C++ is inbuilt function in “cctype.h” header file which checks whether the character is printable or not.Isprint returns true for constant cases as Isprint aside from the house character (' '), that returns true.A locale-specific model version of this function (Isprint) exists in cctype header file.-Isprint() function can be used to check any Non-Printing character in a series of sentences.-Isprint() is an Inbuilt function that provides efficient way to handle non printing characters-Isprint() helps to minimize the lines of code for programmer.-Isprint() is in true sense decreases the compilation time of program.Including cctype.h in your program not only ...

Read More

Find elements of an Array which are Odd and Even using STL in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 367 Views

Given with an array and the task is to find the number of odd and even elements in an array using standard template library in C++.To solve this problem we are using the function count_if() present in C++ standard template library. What is a count_if() function?Syntaxcount_if(LowerBound, UpperBound, function)Description − This function returns the number of elements in an array that satisfies the given condition. It takes three parameters.Lower Bound − It points to the first element of an array or any other sequence.Upper Bound − It points to the last element of an array or any other sequence.Function − It ...

Read More

Program for Fahrenheit to Kelvin conversion in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 453 Views

Given with temperature ‘n’ in Fahrenheit and the challenge is to convert the given temperature to kelvin and display it.ExampleInput 1-: 549.96 Output -: Temperature in fahrenheit 549.96 to kelvin : 561.256 Input 2-: 23.45 Output -: Temperature in fahrenheit 23.45 to kelvin : 268.4For converting the temperature from Fahrenheit to Kelvin, there is a formula which is given belowK = 273.5 + ((F - 32.0) * (5.0/9.0))Where, K is temperature in kelvin and F is temperature in FahrenheitApproach used below is as follows −Input temperature in a float variable let’s say FahrenheitApply the formula to convert the temperature into ...

Read More

Program for octal to decimal conversion in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 293 Views

Given with an octal number as an input, the task is to convert the given octal number into a decimal number.Decimal numbers in computer is represented with base 10 and octal number is represented with base 8 starting from the digit 0 till 7 whereas decimal numbers can be any numeric digit starting from 0 – 9.To convert an octal number into a decimal number follow these steps −We will extract digits starting from right to left through a remainder and then multiply it with the power starting from 0 and will be increased by 1 till the (number of ...

Read More

C++ Program to calculate Bitonicity of an Array

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 216 Views

Given with an array of integers and the task is to calculate the bitonicity of a given array using a function.Bitonicity of an array is −Initialised to 0Incremented to 1 when the next element is greater than the previous valueDecremented to 1 when the next element is lesser than the previous valueExampleInput-: arr[] = { 1, 4, 3, 5, 2, 9, 10, 11} Output-: Bitonicity of an array is : 3Explanation −Initialize bitonicity calculating variable let’s say temp with 0.Start from the first element of an array which is 1. Now compare arr[i] and arr[i-1] i.e. compare 4 and 1 ...

Read More

C++ program for hexadecimal to decimal

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 4K+ Views

Given with a hexadecimal number as an input, the task is to convert the given hexadecimal number into a decimal number.Hexadecimal number in computers is represented with base 16 and decimal number is represented with base 10 and represented with values 0 - 9 whereas hexadecimal number have digits starting from 0 – 15 in which 10 is represented as A, 11 as B, 12 as C, 13 as D, 14 as E and 15 as F.To convert a hexadecimal number into a decimal number follow these steps −We will extract digits starting from right to left through a remainder ...

Read More
Showing 501–510 of 809 articles
« Prev 1 49 50 51 52 53 81 Next »
Advertisements