Found 26504 Articles for Server Side Programming

Program to find second most frequent character in C++

Ayush Gupta
Updated on 17-Sep-2020 05:00:42

854 Views

In this problem, we are given string str. Our task is to create a Program to find second most frequent character in C++.Let’s take an example to understand the problemInputstr = “abaacabcba”Output‘b’Solution ApproachTo find the character that is second most frequent in the string. We need to maintain a count array chatCount that is used to store the frequency of each character in the string. And then using the array we will find the character with max and secondMax frequency in the array. And display the second most frequent character.Program to illustrate the working of our solutionExample Live Demo#include #include ... Read More

Program to find root of an equations using secant method in C++

Ayush Gupta
Updated on 19-May-2020 11:51:15

1K+ Views

In this tutorial, we will be discussing a program to find the root of an equation using secant method.For this we will be provided with an equation. Our task is to find the roots of that equation using the iterative secant method.Example Live Demo#include using namespace std; float f(float x) {    float f = pow(x, 3) + x - 1;    return f; } void secant(float x1, float x2, float E) {    float n = 0, xm, x0, c;    if (f(x1) * f(x2) < 0) {       do {          //calculating the ... Read More

Program to find remainder without using modulo or % operator in C++

Ayush Gupta
Updated on 17-Sep-2020 05:03:25

2K+ Views

In this problem, we are given two numbers, N and D. Our task is to create a Program to find remainder without using modulo or % operator in C++.Problem description − We need to find the remainder that will be left after dividing the number N by D. But we cannot use the modulo or % operator for this.Let’s take an example to understand the problemInputN = 53 D = 3Output2Solution ApproachTo find the remainder, a simple approach is to find the number less than N which is the multiple of D. And the substrate the number from N. To ... Read More

Program to find remainder when large number is divided by r in C++

Ayush Gupta
Updated on 17-Sep-2020 05:05:49

524 Views

In this problem, we are given a string num which is a large number and an integer R. Our task is to create a program to find remainder when large number is divided by r in C++.Problem Description − We need to find the remainder when the number defined by the string is divided by r which is a two-digit number.Let’s take an example to understand the problemInputnum = “123423450942121” r = 54Output7Solution ApproachTo find the remainder, we obviously need to divide the number. But dividing huge numbers is a complex process so to ease up the process, we will ... Read More

Program to find remainder when large number is divided by 11 in C++

Ayush Gupta
Updated on 17-Sep-2020 05:07:47

483 Views

In this problem, we are given a string num which is a large number. Our task is to create a program to find remainder when large number is divided by 11 in C++.Problem Description − We need to find the remainder when the number defined by the string is divided by 11.Let’s take an example to understand the problemInputnum = “43212981843718452”Output7Solution ApproachTo find the remainder, we obviously need to divide the number. But dividing huge number is a complex process so to ease up the process, we will divide digit by digit. And store the remainder that follows. This process ... Read More

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

Ayush Gupta
Updated on 19-May-2020 11:43:27

318 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

Program to find Perimeter / Circumference of Square and Rectangle in C++

Ayush Gupta
Updated on 01-Oct-2020 11:22:01

513 Views

In this problem, we are given the side of a square (A) and the length and breadth of a rectangle (L and B). Our task is to create a Program to find Perimeter / Circumference of Square and Rectangle in C++.Problem Description:To find the circumference of a square, we need the side of the square (a). For that, we will use the formula for the perimeter of the square which is 4a.To find the circumference of a rectangle, we need the Length (L) and breadth (B) of the rectangle. For that, we will use the formula for the perimeter of ... Read More

Program to find parity in C++

Ayush Gupta
Updated on 19-May-2020 11:38:59

416 Views

In this tutorial, we will be discussing a program to find parity.For this we will be provided with a number. Our task is to find its parity i.e count of whether the number of ones are odd or even.Example Live Demo# include # define bool int using namespace std; //finding the parity of given number bool getParity(unsigned int n) {    bool parity = 0;    while (n){       parity = !parity;       n = n & (n - 1);    }    return parity; } int main() {    unsigned int n = 7;    cout

Insert the string at the beginning of all items in a list in Python

Mohd Mohtashim
Updated on 16-May-2020 10:50:38

312 Views

In this post we need to enter the string at the beginning of all items in a list. For ex: We're given string = "Tutorials_Point" and List contains multiple element such as "1", "2" etc. So in this we need to add Tutorials_Point in front of "1", "2" and so on.ExampleAproach 1 Live Demosample_list = [1, 2, 3] print(['Tutorials_Point{0}'.format(i) for i in sample_list])Output//['Tutorials_Point1', 'Tutorials_Point2', 'Tutorials_Point3']Approach 2 Live Demosample_list = [1, 2, 3] sample_str = 'Tutorials_Point' sample_str += '{0}' sample_list = ((map(sample_str.format, sample_list))) print(sample_list)Output//['Tutorials_Point1', 'Tutorials_Point2', 'Tutorials_Point3']Read More

Python - int() function

Mohd Mohtashim
Updated on 16-May-2020 10:45:43

3K+ Views

Python int() function converts the specified value into an integer number.The int() function will returns an integer object constructed from a number or string let say x, or return 0 if no argum ents are specified.Syntaxint(value, base) int(x, base=10)value = A number or a string that can be converted into an integer numberbase = A number representing the number format. Default value − 10Example# int() for integers int(10) 10 int(20) 20 # int() for floating point numbers int(11.2) 11 int(9.9e5) 990000

Advertisements