Server Side Programming Articles - Page 2179 of 2650

Program for Surface area of Dodecahedron in C++

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

240 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 factorial of a number in C program

Sunidhi Bansal
Updated on 20-Sep-2019 11:53:49

794 Views

Given with the number n the task is to calculate the factorial of a number. Factorial of a number is calculated by multiplying the number with its smallest or equal integer values.Factorial is calculated as −0! = 1 1! = 1 2! = 2X1 = 2 3! = 3X2X1 = 6 4! = 4X3X2X1= 24 5! = 5X4X3X2X1 = 120 . . . N! = n * (n-1) * (n-2) * . . . . . . . . . .*1ExampleInput 1 -: n=5    Output : 120 Input 2 -: n=6    Output : 720There are multiple methods that ... Read More

Program for EMI Calculator in C program

Sunidhi Bansal
Updated on 20-Sep-2019 11:48:47

859 Views

Given with certain values the program will develop an EMI calculator to generate the needed output. EMI stands for Equated Monthly Installment. So this calculator will generate monthly EMI amount for the user.ExampleInput-: principal = 2000    rate = 5    time = 4 Output-: Monthly EMI is= 46.058037The formula used in the below program is −EMI : (P*R*(1+R)T)/(((1+R)T)-1)where, P indicates loan amount or the Principal amount.R indicates interest rate per monthT indicates loan time period in yearApproach used below is as followsInput principal, rate of interest and time in float variableApply the formula to calculate the EMI amountPrint the ... Read More

Program for Celsius To Fahrenheit conversion in C++

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

808 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

Program for n’th node from the end of a Linked List in C program

Sunidhi Bansal
Updated on 04-Jul-2020 07:01:13

2K+ Views

Given with n nodes the task is to print the nth node from the end of a linked list. The program must not change the order of nodes in a list instead it should only print the nth node from the last of a linked list.ExampleInput -: 10 20 30 40 50 60    N=3 Output -: 40In the above example, starting from first node the nodes till count-n nodes are traversed i.e 10, 20 30, 40, 50, 60 and so the third node from the last is 40.Instead of traversing the entire list this efficient approach can be followed ... Read More

Product of the nodes of a Singly Linked List

Sunidhi Bansal
Updated on 20-Sep-2019 08:01:06

399 Views

Given with n nodes the task is to print the product of all the nodes of a singly linked list. The program must traverse all the nodes of a singly linked list starting from the initial node till the NULL is not found.ExampleInput -: 1 2 3 4 5 Output -: 120In the above example, starting from first node all the nodes are traversed i.e 1, 2 3, 4, 5, 6 and their product is 1*2*3*4*5*6 = 120Approach used below is as followsTake a temporary pointer, lets say, temp of type nodeSet this temp pointer to first node which is ... Read More

Product of the alternate nodes of linked list

Sunidhi Bansal
Updated on 20-Sep-2019 07:50:04

209 Views

Given with n nodes the task is to print the product of alternate node in a linked list. The program must only print the product of alternate nodes without actually changing the locations of the nodes.ExampleInput -: 10 20 30 40 50 60 Output -: 15000In the above example, starting from first node which is 10 alternate nodes are 10, 30, 50 and their product is 10*30*50 = 15000.In the above diagram, blue coloured nodes are the alternate nodes, if we start from first node and red coloured nodes are non considerable nodes.Approach used below is as followsTake a temporary ... 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

C Program to find IP Address, Subnet Mask & Default Gateway

sudhir sharma
Updated on 19-Sep-2019 09:09:18

1K+ Views

C programming language can be used to find the details of the Internet connection of the system. Now, let’s learn about the basics terms that we need in this problem.IP Address − IP Address stands for Internet Protocol address. An IP address is a fixed numerical identification number that is associated with each device. IP address allows communication of your device using IP address over the internet.Subnet Mask − A 32-bit component of the IP address. The subnet mask differentiates the network component of IP address into two parts of the IP address. One being network address and other being ... Read More

Advertisements