Server Side Programming Articles - Page 2154 of 2650

C++ program for hexadecimal to decimal

Sunidhi Bansal
Updated on 18-Oct-2019 08:46:11

4K+ Views

Given with a hexadecimal number as an input, the task is to convert the given hexadecimal number into a decimal number.Hexadecimal number in computers is represented with base 16 and decimal number is represented with base 10 and represented with values 0 - 9 whereas hexadecimal number have digits starting from 0 – 15 in which 10 is represented as A, 11 as B, 12 as C, 13 as D, 14 as E and 15 as F.To convert a hexadecimal number into a decimal number follow these steps −We will extract digits starting from right to left through a remainder ... Read More

C++ Program to calculate Bitonicity of an Array

Sunidhi Bansal
Updated on 18-Oct-2019 08:40:46

180 Views

Given with an array of integers and the task is to calculate the bitonicity of a given array using a function.Bitonicity of an array is −Initialised to 0Incremented to 1 when the next element is greater than the previous valueDecremented to 1 when the next element is lesser than the previous valueExampleInput-: arr[] = { 1, 4, 3, 5, 2, 9, 10, 11} Output-: Bitonicity of an array is : 3Explanation −Initialize bitonicity calculating variable let’s say temp with 0.Start from the first element of an array which is 1. Now compare arr[i] and arr[i-1] i.e. compare 4 and 1 ... Read More

Program for octal to decimal conversion in C++

Sunidhi Bansal
Updated on 18-Oct-2019 08:32:44

247 Views

Given with an octal number as an input, the task is to convert the given octal number into a decimal number.Decimal numbers in computer is represented with base 10 and octal number is represented with base 8 starting from the digit 0 till 7 whereas decimal numbers can be any numeric digit starting from 0 – 9.To convert an octal number into a decimal number follow these steps −We will extract digits starting from right to left through a remainder and then multiply it with the power starting from 0 and will be increased by 1 till the (number of ... Read More

Program for Fahrenheit to Kelvin conversion in C++

Sunidhi Bansal
Updated on 18-Oct-2019 08:29:07

413 Views

Given with temperature ‘n’ in Fahrenheit and the challenge is to convert the given temperature to kelvin and display it.ExampleInput 1-: 549.96 Output -: Temperature in fahrenheit 549.96 to kelvin : 561.256 Input 2-: 23.45 Output -: Temperature in fahrenheit 23.45 to kelvin : 268.4For converting the temperature from Fahrenheit to Kelvin, there is a formula which is given belowK = 273.5 + ((F - 32.0) * (5.0/9.0))Where, K is temperature in kelvin and F is temperature in FahrenheitApproach used below is as follows −Input temperature in a float variable let’s say FahrenheitApply the formula to convert the temperature into ... Read More

Program for Fahrenheit to Celsius conversion in C

Sunidhi Bansal
Updated on 18-Oct-2019 08:25:55

983 Views

Given with temperature ‘n’ in Fahrenheit and the challenge is to convert the given temperature to Celsius and display it.ExampleInput 1-: 132.00 Output -: after converting fahrenheit 132.00 to celsius 55.56 Input 2-: 456.10 Output -: after converting fahrenheit 456.10 to celsius 235.61For converting the temperature from Fahrenheit to Celsius, there is a formula which is given belowT(°C) = (T(°F) - 32) × 5/9Where, T(°C) is temperature in Celsius and T(°F) is temperature in FahrenheitApproach used below is as follows −Input temperature in a float variable let’s say FahrenheitApply the formula to convert the temperature into CelsiusPrint celsiusAlgorithmStart Step 1-> ... Read More

Program for decimal to hexadecimal conversion in C++

Sunidhi Bansal
Updated on 18-Oct-2019 08:19:35

2K+ Views

Given with a decimal number as an input, the task is to convert the given decimal number into a hexadecimal number.Hexadecimal number in computers is represented with base 16 and decimal number is represented with base 10 and represented with values 0 - 9 whereas hexadecimal number have digits starting from 0 – 15 in which 10 is represented as A, 11 as B, 12 as C, 13 as D, 14 as E and 15 as F.To convert a decimal number into a hexadecimal number follow the given steps −Firstly divide the given number with the base value of conversion ... Read More

Program for Decimal to Binary Conversion in C++

Sunidhi Bansal
Updated on 18-Oct-2019 08:13:18

304 Views

Given with a decimal number as an input, the task is to convert the given decimal number into a binary number.Decimal number in computers is represented with base 10 and binary number is represented with base 2 as it has only two binary digits 0 and 1 whereas decimal numbers can be any numeric digit starting from 0 – 9.To convert a decimal number into a binary number follow the given steps −Firstly divide the given number with the base value of conversion number e.g. dividing 42 by 2 because we need to convert 42 into a binary numbers which ... Read More

Program for Binary To Decimal Conversion in C++

Sunidhi Bansal
Updated on 18-Oct-2019 08:08:55

380 Views

Given with a binary number as an input, the task is to convert the given binary number into a decimal number.Decimal number in computers is represented with base 10 and binary number is represented with base 2 as it has only two binary digits 0 and 1 whereas decimal numbers can be any numeric digit starting from 0 – 9.To convert a binary number into a decimal number we will extract digits starting from right to left through a remainder and then multiply it with the power of 2 starting from 0 and will be increased by 1 till the ... Read More

Program to convert IP address to hexadecimal in C++

Sunidhi Bansal
Updated on 18-Oct-2019 08:04:25

794 Views

Given with the input as an IP address value and the task is to represent the given IP address as its hexadecimal equivalent.What is IP addressIP address or Internet protocol is a unique number to that uniquely describes your hardware connected to a network. Internet means over the network and protocol defines the set of rules and regulations that must be followed for connection. Because of IP address only it is possible for a system to communicate with another system over a network. There are two versions of IP that are −IPv4(Internet Protocol Version 4)IPv6(Internet Protocol Version 6)IP address is ... Read More

Program to convert KiloBytes to Bytes and Bits in C++

Sunidhi Bansal
Updated on 18-Oct-2019 07:59:50

1K+ Views

Given with the input as KiloBytes and the task is to convert the given input into number of bytes and bits.Bit − In computers, bit is the smallest unit represented with two integer value 0 and 1 and all the information in computer is processed as a sequence of these two digits.N-bits = 2 ^ N patterns, where N can be any integer value starting from 1.Byte − In computers, byte is represented with 8 bits. Byte is capable of holding one character to numbers ranging between 0 and 255.1 byte = 8 bitsWhich means 2 ^ 8 patterns which ... Read More

Advertisements