Found 7197 Articles for C++

C++ Program to Check Whether a Number is Positive or Negative

Arnab Chakraborty
Updated on 19-Oct-2022 10:44:04

5K+ Views

In modern programming languages we work with signed numbers and unsigned numbers also. For signed numbers the numbers can be positive or negative or zero. To represent negative numbers, the systems store the numbers in 2’s complement method. In this article we shall discuss how to determine a given number is positive, or negative in C++. Checking using if-else conditions The basic sign checking can be done by using if else conditions. The syntax for the if-else conditions is like below − Syntax if { perform action when condition is true } else { ... Read More

C++ Program to convert the Binary number to Gray code using recursion

Arnab Chakraborty
Updated on 19-Oct-2022 10:42:21

891 Views

Gray codes or reflected binary codes are a special type of binary representation of numbers in which two successive values differ in only one bit. For example, the binary equivalent of 1 and 2 are 01 and 10, here two bits are changing. But in gray code, the 1 is 01 and 2 is 11, only one bit is changing. In this article, we will see how we can convert a given binary number into its gray code equivalent by using recursion in C++. Passing number as a decimal integer In the first example, we are providing the number in ... Read More

C++ Program to pass a string to the function

Arnab Chakraborty
Updated on 19-Oct-2022 12:42:32

23K+ Views

Any programming language that uses functions has code that is simpler, more modular, and simpler to change while being debugged. Functions are a remarkably beneficial component in a modular piece of code. A function can take arguments and perform certain operations on them. Like other primitive datatypes, we can also pass object types or arrays as an argument. In this article, we will see how to pass string-type data as a function argument in C++. Passing C++ like string argument to a function C++ supports stronger string objects which is actually a class with different member functions associated with them. ... Read More

C++ Program to create a function with arguments and a return value

Arnab Chakraborty
Updated on 19-Oct-2022 09:26:23

4K+ Views

Any programming language that uses functions has code that is simpler, more modular, and simpler to change while being debugged. Functions are a remarkably beneficial component in a modular piece of code. A function's ability to accept arguments and output results. It is not necessarily necessary for a function to accept inputs and to always produce a result. There are numerous instances where functions only take a few inputs and don't return anything. does not always respond and will not tolerate disputes. This article will explain how to create C++ programmes that use functions, which accept a number of arguments ... Read More

C++ Program to create a function with arguments but without a return value

Arnab Chakraborty
Updated on 19-Oct-2022 09:24:05

2K+ Views

Functions in functional programming are used to create modular codes. We construct submodules in many applications to make our code simple to write, simple to debug, and also efficient by avoiding writing needless code repeatedly. Functions have a role in achieving these traits. Functions frequently take arguments and produce a result. It occasionally might not accept any arguments but still produce something. There are several rare circumstances when functions take a few inputs but don't return anything. This course will discuss C++ methods that accept arguments but nothing is returned. Function with arguments but no return value To define a ... Read More

C++ Program to create a function without argument and without a return value

Arnab Chakraborty
Updated on 19-Oct-2022 09:22:42

6K+ Views

Functions in programming languages are used to make codes modular. In many applications, we create sub-modules to make our code easy to write, easy to debug, and also optimized by rejecting unnecessary code again and again. To achieve these features, functions come into the picture. In many cases, functions take arguments and return something. Sometimes it may not take any argument but returns something. Some special cases are also there when the functions do not take any arguments and do not return anything. In this tutorial, we shall cover such functions without argument and return value in C++. Function without ... Read More

C++ Program to Find the Product of Two Numbers Using Recursion

Arnab Chakraborty
Updated on 19-Oct-2022 09:19:42

3K+ Views

Recursion is a technique where we call a function from the same function itself. There must be some base or terminating condition to end the recursive call. Recursive procedures are very much helpful to perform complex iterative solution with fewer codes and easier solution approach through sub-operation finding. In this article we shall discuss a recursive approach to perform product (multiplication) between two numbers in C++. Initially we will understand the basic principle, the syntax for recursive function call, the algorithm and the source code. Multiplication using Recursion In high-level languages, there is the multiplication operators available to directly perform ... Read More

C++ Program to convert the string into a floatingpoint number

Arnab Chakraborty
Updated on 19-Oct-2022 09:17:34

811 Views

Static typing is used in the C++. Variables must be defined with a specific type in order to write programmes. Inputs from the console or files must occasionally be read. In this case, the programme is given the string data. Special operations are necessary to transform them into other datatypes. This article will provide the C++ method for converting strings to floating point integers. A couple different methods can be used to accomplish this. Explore each of them separately. Using stringstream in C++ Streams are a fantastic tool in C++. Filestreams, standard input/output streams, etc. are examples of these streams. ... Read More

C++ program to convert the string into an integer

Arnab Chakraborty
Updated on 09-Dec-2024 18:40:33

12K+ Views

C++ is a statically typed language. To write programs we need to define variables of specified types. Sometimes we need to read inputs from the console or files. In such a scenario the string data are read into the program. To convert them into other datatypes needs special operations. In this article, we shall discuss how to convert strings to integers in C++. There are a few different techniques to do so. Let us explore them one by one. String to Integer Using stringstream Class C++ uses streams for different applications. Such streams are filestreams, standard input/output streams, etc. There ... Read More

C++ Program to find the hyperbolic arctangent of the given value

Arnab Chakraborty
Updated on 19-Oct-2022 08:49:04

198 Views

The hyperbola, rather than the circle, is used to define hyperbolic functions. It returns the ratio parameter for the hyperbolic tangent function based on the supplied radian angle. On the contrary, however. To calculate the angle from the hyperbolic-tangent value, inverse hyperbolic trigonometric procedures like the hyperbolic arctangent operation are required. This article will demonstrate how to utilize the C++ hyperbolic inverse-tangent (atanh) function to determine the angle using the hyperbolic tangent value, in radians. The hyperbolic inverse-tangent operation has the following formula − $$\mathrm{cosh^{-1}x\:=\:\frac{1}{2}In\left(\frac{1\:+\:x}{1\:-\:x}\right)}, where \:In\: is\: natural\: logarithm\:(log_e \: k)$$ The atanh() function The angle can be calculated ... Read More

Advertisements