Programming Articles - Page 2435 of 3363

C Program for Number of stopping station problem

sudhir sharma
Updated on 19-Sep-2019 08:49:57

629 Views

Problem statement − A program to find the number of ways in which a train will stop in r stations out of n stations so that no two stopping stations are consecutive.Problem ExplanationThis program will calculate the number of ways i.e. permutations in which the train will stop. Here, the train will travel from point X to Y. Between these points, there are n stations. The train will stop on r stations of these n stations given the conditions that while stopping on r stations the train should not stop in two consecutive stations.This permutation can be found using the ... Read More

What is the Address of a function in C or C++?

sudhir sharma
Updated on 19-Sep-2019 08:44:02

3K+ Views

A function is a block of code that is defined to perform a specific piece of work in a program. It is used to ease the work of the programmer by defining a commonly occurring piece of code so that it can be reused when required.The address is the memory location where the entity is stored. Every block of code in the program has its own memory location in the program. Which means like any variable or object methods and functions also have memory address.To get the memory address of a function you need to use the pointer of the ... Read More

Adding two polynomials using Linked List in C++.

Manisha Chand
Updated on 06-Aug-2025 19:24:24

28K+ Views

Adding two Polynomials using a Linked List in C++ Linked list is a data structure that stores each element as an object in a node of the list. Every node contains two parts data node and links to the next node. A polynomial is a mathematical expression that consists of variables and coefficients. For example, x^2 - 4x + 7. In the Polynomial linked list, the coefficients and exponents of the polynomial are defined as the data node of the list. For example, if the given Polynomial equation is: 4x7 + 12x2 + 45. Its representation in a linked list looks like: ... Read More

Adding elements of an array until every element becomes greater than or equal to k in C++.

sudhir sharma
Updated on 19-Sep-2019 08:32:43

255 Views

Array − An array is a container of elements of the same data type, whose elements are 0 indexed.In this problem, we will use an array of integers. And check if all the elements are greater than the given number or not. Here we will check if all elements of the array are greater than or equal to a given number k. If not then we will add two minimum elements of the array and treat this sum as a single element. And then again check for the same condition for the new array. If the condition comes out to ... Read More

How can we convert a list to the JSON array in Java?

Aishwarya Naglot
Updated on 22-Apr-2025 14:25:07

33K+ Views

Converting a list to a JSON array is one of the common tasks in Java. Let's see how to convert a list to a JSON array in Java. If you do not know what JSON is, then you can read the JSON tutorial. The following are various ways to convert a list to a JSON array in Java: Manual construction of JSON array Using Jackson library Using Gson library Using org.json library Let's learn the process of each of them one by ... Read More

Add two unsigned numbers using bits in C++.

Nishu Kumari
Updated on 23-Jul-2025 18:12:49

818 Views

In this problem, we are given two unsigned numbers, and we need to add them using bits in C++. Bits are binary digits that can be either 0 or 1. Unsigned numbers are positive numbers represented by these bits. To add two unsigned numbers, we add their bits one by one using binary addition rules. Binary addition works like decimal addition, but with simpler rules: 1 + 0 = 1 0 + 1 = 1 0 + 0 = 0 1 + 1 ... Read More

Add two numbers using ++ operator in C++.

Nishu Kumari
Updated on 25-Jul-2025 12:41:43

943 Views

Adding two numbers is a basic arithmetic operation, where we simply combine their values to get the total. The given task is to add two numbers using the "++" operator in C++. Let's understand this with an example: Scenario 1 // Adding two numbers using '+' operator Input: a = 7, b = 3 Output: 10 Explanation: a + b => 7 + 3 = 10 Scenario 2 // Adding two numbers using '++' operator Input: a = 7, b = 3 Output: 10 Explanation: a + b => 7 + 1 + ... Read More

Add two numbers represented by two arrays in C Program

sudhir sharma
Updated on 19-Sep-2019 08:18:23

2K+ Views

A number represented by the array is stored in such a form that each digit of the number is represented by an element of the array. For example, Number 234 in array is {2, 3, 4}.To add to such numbers we will first add number at the least significant digit and if the sum is greater than 10 propagate the carry. After this, we will go for the next consecutive digits of the array doing the same procedure and finding the sum.Let’s take an example to add two numbers −a = {2, 9, 6} b = {6, 3, 8} Output: ... Read More

How to get the primitive value of string in Javascript?

Abdul Rawoof
Updated on 26-Aug-2022 11:54:55

1K+ Views

In JavaScript if the data is not an object and has no methods and properties is called as a primitive data type or a primitive value. The different types of primitive data types in JavaScript are string, number, Boolean, undefined, symbol, null and big int. The primitive types boolean, string and number can be wrapped by their wrapper object, i.e., instances of the Boolean, String and Number constructors respectively. To get the back the primitive values back from the object wrappers, we need to call the valueOf() method on the objects. Example Following example demonstrates the primitive and object types ... Read More

C/C++ Tricky Programs

sudhir sharma
Updated on 19-Sep-2019 08:11:14

5K+ Views

Here are 10 tricky programs that will test your programming basics.1. Program to print “ ” in C++In C++ programming language, we use quotes to denote the start and end of the text is to be printed. So, printing quotes “ needs a special escape sequence. So, we will use the \” to print quotes in c++.Example Live Demo#include using namespace std; int main() {    cout

Advertisements