Ayush Gupta

Ayush Gupta

433 Articles Published

Articles by Ayush Gupta

Page 2 of 44

Program to find count of numbers having odd number of divisors in given range in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 449 Views

In this tutorial, we will be discussing a program to find the count of numbers having odd number of divisors in a given range.For this we will be provided with the upper and lower limits of the range. Our task is to calculate and count the number of values having an odd number of divisors.Example#include using namespace std; //counting the number of values //with odd number of divisors int OddDivCount(int a, int b){    int res = 0;    for (int i = a; i

Read More

Program to find covariance in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 772 Views

In this tutorial, we will be discussing a program to find covariance.For this we will be provided with two sets of random variables. Our task is to calculate their covariance i.e, the measure of how much those two values differ together.Example#include using namespace std; //function to find mean float mean(float arr[], int n){    float sum = 0;    for(int i = 0; i < n; i++)    sum = sum + arr[i];    return sum / n; } //finding covariance float covariance(float arr1[], float arr2[], int n){    float sum = 0;    for(int i = 0; i < ...

Read More

Program to find Cullen Number in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 173 Views

In this tutorial, we will be discussing a program to find Cullen Number.For this we will be provided with an integer. Our task is to find the cullen number at that position using the formula −2n* n + 1Example#include using namespace std; //finding the nth cullen number unsigned get_cullen(unsigned n){    return (1

Read More

Program to find equation of a plane passing through 3 points in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 459 Views

In this tutorial, we will be discussing a program to find equation of a plane passing through 3 points.For this we will be provided with 3 points. Our task is to find the equation of the plane consisting of or passing through those three given points.Example#include #include #include #include using namespace std; //finding the equation of plane void equation_plane(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3){    float a1 = x2 - x1;    float b1 = y2 - y1;    float c1 = z2 - z1; ...

Read More

Program to find first N Iccanobif Numbers in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 157 Views

In this tutorial, we will be discussing a program to find N lccanobif numbers.For this we will be provided with an integer. Our task is to find the lccanobif number at that position. They are similar to the fibonacci number except the fact that we add the previous two numbers after reversing their digits.Example#include using namespace std; //reversing the digits of a number int reverse_digits(int num){    int rev_num = 0;    while (num > 0) {       rev_num = rev_num * 10 + num % 10;       num = num / 10;    } ...

Read More

Program to find GCD of floating point numbers in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 551 Views

In this tutorial, we will be discussing a program to find GCD of floating point numbers.For this we will be provided with two integers. Our task is to find the GCD (Greatest common divisor) of those two provided integers.Example#include using namespace std; //returning GCD of given numbers double gcd(double a, double b){    if (a < b)       return gcd(b, a);    if (fabs(b) < 0.001)       return a;    else       return (gcd(b, a - floor(a / b) * b)); } int main(){    double a = 1.20, b = 22.5;    cout

Read More

Program to find GCD or HCF of two numbers using Middle School Procedure in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 1K+ Views

In this tutorial, we will be discussing a program to find GCD or HCF of two numbers using Middle School Procedure.For this we will be provided with two numbers. Our task is to find the GCD (greatest common divisor) or HCF (highest common factor) for the given values.Example#include #define MAXFACTORS 1024 using namespace std; //structure to store factorization typedef struct{    int size;    int factor[MAXFACTORS + 1];    int exponent[MAXFACTORS + 1]; } FACTORIZATION; void FindFactorization(int x, FACTORIZATION* factorization){    int i, j = 1;    int n = x, c = 0;    int k = 1; ...

Read More

Program to find greater value between a^n and b^n in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 202 Views

In this tutorial, we will be discussing a program to find greater value between a^n and b^n.For this we will be provided with three numbers. Our task is to calculate a^n and b^n and return back the greater of those values.Example#include using namespace std; //finding the greater value void findGreater(int a, int b, int n){    if (!(n & 1)) {       a = abs(a);       b = abs(b);    }    if (a == b)       cout b)       cout

Read More

Maximum of smallest possible area that can get with exactly k cut of given rectangular in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 180 Views

In this tutorial, we will be discussing a program to find the maximum of smallest possible area that can get with exactly k cut of given rectangular.For this we will be provided with the sides of the rectangle and the number of cuts that can be made. Our task is to calculate the smallest area that can be achieved by making the given number of cuts.Example#include using namespace std; void max_area(int n, int m, int k) {    if (k > (n + m - 2))       cout

Read More

Maximum of sum and product of digits until number is reduced to a single digit in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 323 Views

In this tutorial, we will be discussing a program to find maximum of sum and product of digits until number is reduced to a single digitFor this we will be provided with a random number. Our task is to find and print out the maximum of sum and product of the digits of the given number until it coverts to a single digitExample#include using namespace std; //converting number to single digit by adding long repeatedSum(long n) {    if (n == 0)       return 0;    return (n % 9 == 0) ? 9 : (n % 9); ...

Read More
Showing 11–20 of 433 articles
« Prev 1 2 3 4 5 44 Next »
Advertisements