Found 7347 Articles for C++

C++ Floating Point Manipulation

sudhir sharma
Updated on 19-Sep-2019 09:16:51

1K+ Views

Numerical implementation of a decimal number is a float point number. In C++ programming language the size of a float is 32 bits. And there are some floating point manipulation functions that work on floating-point numbers. Here we have introduced some of the floating-point manipulation functions.fmod()The fmod() function operating on floats will return the remainder of the division of the passed arguments of the method.Example Live Demo#include #include using namespace std; int main() {    float a, b, rem;    a = 23.4;    b = 4.1;    rem = fmod(a,b);    cout

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

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

2K+ 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++.

sudhir sharma
Updated on 04-Nov-2023 01:44:16

23K+ Views

To understand this concept better let's first brush up all the basic contents that are required.linked list is a data structure that stores each element as an object in a node of the list. every note contains two parts data han and links to the next node.Polynomial is a mathematical expression that consists of variables and coefficients. for example x^2 - 4x + 7In the Polynomial linked list, the coefficients and exponents of the polynomial are defined as the data node of the list.For adding two polynomials that are stored as a linked list. We need to add the coefficients ... 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

145 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

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

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

686 Views

In programming, the ++ operator is the increment operator that increases the value of the operand by 1. We can add two numbers using this operator by adding 1 to the number a, b number of times.Example,Input: a = 31 , b = 4 Output: 35Explanation − adding 1 to 31 four times, sums up to 31 +1+1+1+1 = 35.AlgorithmInput: two integers a and b. Step 1: loop from 0 to b and follow step 2. Step 2: add 1 to b. Step 3: print the value of a.Example Live Demo#include using namespace std; int main(){    int x = 324 , y= 76;    cout

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

C/C++ Program for Greedy Algorithm to find Minimum number of Coins

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

5K+ Views

A greedy algorithm is an algorithm used to find an optimal solution for the given problem. greedy algorithm works by finding locally optimal solutions ( optimal solution for a part of the problem) of each part so show the Global optimal solution could be found.In this problem, we will use a greedy algorithm to find the minimum number of coins/ notes that could makeup to the given sum. For this we will take under consideration all the valid coins or notes i.e. denominations of { 1, 2, 5, 10, 20, 50 , 100, 200 , 500 ,2000 }. And we ... Read More

C++ vs C#

sudhir sharma
Updated on 19-Sep-2019 07:57:35

183 Views

C++ Programming languageA successor of the c programming language that has introduced the concept of classes and objects. It encapsulates features of c and high-level language hence it can be treated as an intermediate-level language. When it was created it was thought of as a C that has classes because of its similarities with C.C# Programming LanguageC# (also known as C sharp) is a general-purpose programming language that was developed by Microsoft to run on .net framework for developing applications for its operating system. It is an object-oriented programming language with features like object-oriented, statically typed, decorative, multiparadigm programming language.Both ... Read More

C++ Stream Classes Structure

sudhir sharma
Updated on 26-Oct-2023 03:24:39

22K+ Views

In C++ stream refers to the stream of characters that are transferred between the program thread and i/o.Stream classes in C++ are used to input and output operations on files and io devices. These classes have specific features and to handle input and output of the program.The iostream.h library holds all the stream classes in the C++ programming language.Let's see the hierarchy and learn about them, Now, let’s learn about the classes of the iostream library.ios class − This class is the base class for all stream classes. The streams can be input or output streams. This class defines members that ... Read More

C++ program to print unique words in a file

sudhir sharma
Updated on 19-Sep-2019 07:39:36

435 Views

A file is a memory location that stores word streams. In a file, there are various words. In this program, we will find all unique words from the file and print them.A unique word means the number of occurrences of the word is one in the file.For example, Tutorials point is best for programming tutorials.Here, the word tutorial occurs more than once, hence it is not unique. Rest all words are unique.AlgorithmTo check for unique words in the given file. Using iterator with two variables : data and occurence. Input : File Step 1 : Read each line from the ... Read More

Advertisements