Ayush Gupta

Ayush Gupta

433 Articles Published

Articles by Ayush Gupta

Page 20 of 44

Program to find Prime Numbers Between given Interval in C++

Ayush Gupta
Ayush Gupta
Updated on 19-May-2020 364 Views

In this tutorial, we will be discussing a program to find prime numbers between given intervals.For this we would be provided with two integers. Our task is to find the prime numbers in that particular range.Example Live Demo#include using namespace std; int main() {    int a, b, i, j, flag;    //getting lower range    a = 3;    //getting upper range    b = 12;    cout

Read More

Program to find N-th term of series 3, 12, 29, 54, 86, 128, 177, 234, ….. in C++

Ayush Gupta
Ayush Gupta
Updated on 15-May-2020 130 Views

In this tutorial, we will be discussing a program to find N-th term of series 3, 12, 29, 54, 86, 128, 177, 234, …..For this we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include #include using namespace std; //calculating nth term of given series int nthTerm(int n) {    return 4 * pow(n, 2) - 3 * n + 2; } int main() {    int N = 4;    cout

Read More

Program to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, …in C++

Ayush Gupta
Ayush Gupta
Updated on 04-May-2020 159 Views

In this tutorial, we will be discussing a program to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, …For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include #include using namespace std; //calculating nth term of given series int nthTerm(int n) {    return 3 * pow(n, 2) - 4 * n + 2; } int main() {    int N = 4;    cout

Read More

Program to find N-th term of series 0, 10, 30, 60, 99, 150, 210, 280...in C++

Ayush Gupta
Ayush Gupta
Updated on 04-May-2020 200 Views

In this tutorial, we will be discussing a program to find N-th term of series 0, 10, 30, 60, 99, 150, 210, 280...For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include #include using namespace std; //calculating nth term of series int nthTerm(int n) {    return 5 * pow(n, 2) - 5 * n; } int main() {    int N = 4;    cout

Read More

Program to find N-th term of series 0, 7, 8, 33, 51, 75, 102, 133...in C++

Ayush Gupta
Ayush Gupta
Updated on 04-May-2020 143 Views

In this tutorial, we will be discussing a program to find N-th term of series 0, 7, 8, 33, 51, 75, 102, 133...For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include #include using namespace std; //calculating nth term of series int nthTerm(int n) {    return 2 * pow(n, 2) + n - 3; } int main() {    int N = 4;    cout

Read More

Program to find HCF iteratively in C++

Ayush Gupta
Ayush Gupta
Updated on 04-May-2020 285 Views

In this tutorial, we will be discussing a program to find HCF iteratively.For this, we will be provided with two numbers. Our task is to calculate the HCF of the given numbers using an iterative function.Example Live Demo#include using namespace std; int get_HCF(int a, int b){    while (a != b){       if (a > b)          a = a - b;       else          b = b - a;    }    return a; } int main(){    int a = 60, b = 96;    cout

Read More

Program to find N-th term of series 3, 5, 33, 35, 53… in C++

Ayush Gupta
Ayush Gupta
Updated on 04-May-2020 187 Views

In this tutorial, we will be discussing a program to find N-th term of series 3, 5, 33, 35, 53…For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include using namespace std; //finding the nth term in the series int printNthElement(int n){    int arr[n + 1];    arr[1] = 3;    arr[2] = 5;    for (int i = 3; i

Read More

Program to find Circumcenter of a Triangle in C++

Ayush Gupta
Ayush Gupta
Updated on 14-Apr-2020 650 Views

In this tutorial, we will be discussing a program to find the circumcenter of a triangle.For this we will be provided with three noncollinear points. Our task is to find the circumcenter of the triangle formed by those points.Example Live Demo#include #include using namespace std; //storing X and Y values #define pdd pair void lineFromPoints(pdd P, pdd Q, double &a, double &b, double &c){    a = Q.second - P.second;    b = P.first - Q.first;    c = a*(P.first)+ b*(P.second); } void perpendicularBisectorFromLine(pdd P, pdd Q, double &a, double &b, double &c){    pdd mid_point = make_pair((P.first + ...

Read More

Program to find century for a year in C++

Ayush Gupta
Ayush Gupta
Updated on 14-Apr-2020 711 Views

In this tutorial, we will be discussing a program to find the century for a year.For this we will be provided with a year. Our task is to find the century in which the given year falls.Example Live Demo#include using namespace std; void find_century(int year){    //year values can only be positive    if (year

Read More

Program to find area of a Circular Segment in C++

Ayush Gupta
Ayush Gupta
Updated on 14-Apr-2020 275 Views

In this tutorial, we will be discussing a program to find area of a circular segment.Making a chord in a given sphere divides it into two segments - major and minor. Given the radius of the circle and angle making the minor segment, we are required to find the areas of both segments.Example Live Demo#include using namespace std; float pi = 3.14159; //finding area of segment float area_of_segment(float radius, float angle){    float area_of_sector = pi * (radius * radius)*(angle / 360);    float area_of_triangle = (float)1 / 2 *(radius * radius) *     sin((angle * pi) ...

Read More
Showing 191–200 of 433 articles
« Prev 1 18 19 20 21 22 44 Next »
Advertisements