Found 7197 Articles for C++

Program for Surface area of Dodecahedron in C++

Sunidhi Bansal
Updated on 20-Sep-2019 11:58:55

232 Views

What is Dodecahedron?The word ‘dodecahedron’ is derived from the Greek words where, dodeca means ‘twelve’ and hedron specifies ‘faces’. Dodecahedron in geometric is a 3-D platonic or regular solid with twelve flat faces. Like, other figures dodecahedron also have properties and those are −20 polyhedron vertices30 polyhedron edges12 pentagonal faces, as a pentagon is a five-sided polygonGiven below is the figure of dodecahedronProblemGiven with an edge, the program must find the surface area of dodecahedron where surface area is the total space occupied by the faces of the given figure.To calculate surface area of dodecahedron there is a formula −ExampleInput-: ... Read More

Program for Celsius To Fahrenheit conversion in C++

Sunidhi Bansal
Updated on 20-Sep-2019 08:30:20

800 Views

Given with temperature ‘n’ in Celsius the challenge is to convert the given temperature to Fahrenheit and display it.ExampleInput 1-: 100.00    Output -: 212.00 Input 2-: -40    Output-: -40For converting the temperature from Celsius to Fahrenheit there is a formula which is given belowT(°F) = T(°C) × 9/5 + 32Where, T(°C) is temperature in Celsius and T(°F) is temperature in FahrenheitApproach used below is as followsInput temperature in a float variable let’s say CelsiusApply the formula to convert the temperature into FahrenheitPrint FahrenheitALGORITHMStart Step 1 -> Declare a function to convert Celsius to Fahrenheit    void cal(float cel) ... Read More

C++ Interview questions based on constructors/ Destructors

sudhir sharma
Updated on 19-Sep-2019 10:36:22

1K+ Views

C++ interview questions on ConstructorsWhat is a constructor?A constructor is a function of a class that has the same name as the class. The constructor is called at the time of the initialization of object. There are three types of constructors −Default constructorParameterized constructorCopy constructorSyntaxclass cl_name{    cl_name(){       //This is constructor..    } }What is a destructor?A destructor is a method of a class that has the same name as the class preceded by a tild ~ symbol. It is called at the end of code or when the object is destroyed or goes out of scope.Syntaxclass ... Read More

C++ Floating Point Manipulation

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

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

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

27K+ 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

230 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++.

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

875 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

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

6K+ 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

Advertisements