Server Side Programming Articles - Page 2153 of 2650

C++ program to calculate Profit Or Loss

Sunidhi Bansal
Updated on 18-Oct-2019 11:18:06

4K+ Views

Given with the cost price(CP) and the selling price(SP) and the task is to calculate the profit gained or loss incurred.Cost price or CP is the price at which the product is purchased by the seller and the selling price or SP is the price at which the product is sold by the seller.There is a formula to calculate profit gained or loss incurredProfit = Selling price – Cost priceIf Selling price is greater than cost price than there will be a profitLoss = Cost price – Selling priceIf cost price is greater than selling price than there will be ... Read More

C++ program to calculate GST from original and net prices

Sunidhi Bansal
Updated on 18-Oct-2019 11:13:59

2K+ Views

Given with the original cost and net price as an input and the task is to calculate the GST percentage and display the resultGST stands for Goods and Service task. It is always included in the Net price of the product and before calculating the GST percentage we need to calculate GST amount and for that there are formulas availableNetprice = originalcost + GSTAmountGSTAmount = Netprice – original_costGST_Percentage = (GSTAmount * 100)/ originalcostGST % formula = (GSTAmount*100) / originalcostExampleInput-: cost = 120.00    price = 150.00 Output-: GST amount is = 25.00 % Input-: price = 120.00    cost = ... Read More

C program to calculate distance between two points

Sunidhi Bansal
Updated on 18-Oct-2019 11:10:35

3K+ Views

Given with the two points coordinates and the task is to find the distance between two points and display the result.In a two dimension plane there are two points let’s say A and B with the respective coordinates as (x1, y1) and (x2, y2) and to calculate the distance between them there is a direct formula which is given below$$\sqrt{\lgroup x2-x1\rgroup^{2}+\lgroup y2-y1\rgroup^{2}}$$Given below is the diagram representing two points and their differences$$\frac{(x_2-x_1)}{(x_1, y_1)\:\:\:\:\:\:(y_2-y_1)\:\:\:\:\:\:(x_2, y_2)}$$Approach used below is as follows −Input the coordinates as x1, x2, y1 and y2Apply the formula to compute the difference between two pointsPrint the distanceAlgorithmStart Step ... Read More

C program to calculate distance between three points in 3D

Sunidhi Bansal
Updated on 18-Oct-2019 11:02:39

1K+ Views

Given with the 3-D plane and hence three coordinates and the task is to find the distance between the given points and display the result.In a three dimension plane there are three axis that are x-axis with its coordinates as (x1, y1, z1), y-axis with its coordinates as (x2, y2, z2) and z-axis with its coordinates as (x3, y3, z). To calculate the distance between them there is a direct formula which is given below$$\sqrt{\lgroup x2-x1\rgroup^{2}+\lgroup y2-y1\rgroup^{2}+\lgroup z2-z1\rgroup^{2}}$$Given below is the diagram representing three different axis and their coordinatesApproach used below is as follows −Input the coordinates as (x1, y1, ... Read More

C program to calculate age

Sunidhi Bansal
Updated on 18-Oct-2019 10:57:19

28K+ Views

Given with the current date and the birth date of a person and the task is to calculate his current age.ExampleInput-: present date-: 21/9/2019    Birth date-: 25/9/1996 Output-: Present Age    Years: 22 Months:11 Days: 26Approach used below is as follows −Input the current date and birth date of a personCheck for the conditionsIf current month is less than the birth month, then we will not consider the current year because this year has not been completed yet and to compute the differences in months by adding 12 to the current month.If the current date is less than the ... Read More

C program to Calculate Body Mass Index (BMI)

Sunidhi Bansal
Updated on 18-Oct-2019 09:15:50

11K+ Views

Given with the weight and height of a person and the task is to find the BMI i.e. body mass index of his body and display it.For calculating the body mass index we require two things −WeightHeightBMI can be calculated using the formula given below −BMI = (mass or weight) / (height*height)Where weight is in kg and height is in metersExampleInput 1-: weight = 60.00    Height = 5.1 Output -: BMI index is : 23.53 Input 2-: weight = 54.00    Height = 5.4 Output -: BMI index is : 9.3Approach used below is as follows −Input weight(kg) and ... Read More

C++ program to check for ISBN

Sunidhi Bansal
Updated on 18-Oct-2019 09:10:26

1K+ Views

Given with the sequence and the task is to identify whether the given sequence is sa ISBN number or not.What is an ISBN numberISBN stands for International Standard Book Number is a 10 digit number till December 2006 and now it is revised to 13 digit number from 1 January 2007. Given below is the implementation of 10 digits ISBN.ISBN digit has a pattern in it as −Starting 9 digits of a number represents Title, Publisher and Group of the book. The value of first 9 digit can range from 0 - 9Last 1 digit checks whether the ISBN is ... Read More

C++ program for multiplication of array elements

Sunidhi Bansal
Updated on 18-Oct-2019 09:03:59

7K+ Views

Given with an array of integer elements and the task is to multiply the elements of an array and display it.ExampleInput-: arr[]={1, 2, 3, 4, 5, 6, 7} Output-: 1 x 2 x 3 x 4 x 5 x 6 x 7 = 5040 Input-: arr[]={3, 4, 6, 2, 7, 8, 4} Output-: 3 x 4 x 6 x 2 x 7 x 8 x 4 = 32256Approach used in the below program is as follows −Initialize temporary variable to store the final result with 1Start loop from 0 to n where n is the size of an arrayKeep multiplying ... Read More

C++ program for length of the longest word in a sentence

Sunidhi Bansal
Updated on 18-Oct-2019 09:01:01

1K+ Views

Given with the sentence of multiple strings and the task is to find the length of the longest string in the sentence.ExampleInput-: hello I am here Output-: maximum length of a word is: 5 Input-: tutorials point is the best learning platform Output-: maximum length of a word is: 9Approach used in the below program is as follows −Input the string in an array of stringsTraverse the loop till the end of a sentence is not foundTraverse one particular string of a sentence and calculate its length. Store the length in a variablePass the integer values of length of strings ... Read More

C++ program for length of a string using recursion

Sunidhi Bansal
Updated on 18-Oct-2019 08:50:22

714 Views

Given with the string and the task is to calculate the length of the given string using a user defined function or in-built function.Length of a string can be calculated using two different ways −Using user defined function − In this, traverse the entire string until ‘\o’ is found and keep incrementing the value by 1 through recursive call to a function.Using user in-build function − There is an in-build function strlen() defined within “string.h” header file which is used for calculating the length of a string. This function takes single argument of type string and return integer value as ... Read More

Advertisements