C Program for N-th Term of Geometric Progression Series

Sunidhi Bansal
Updated on 20-Nov-2019 11:06:09

5K+ Views

Given ‘a’ the First term, ‘r’ the common ratio and ‘n’ for the number of terms in a series. The task is to find the nth term of the series.So, before discussing how to write a program for the problem first we should know what is Geometric Progression.Geometric progression or Geometric sequence in mathematics are where each term after the first term is found by multiplying the previous one with the common ratio for a fixed number of terms.Like 2, 4, 8, 16, 32.. is a geometric progression with first term 2 and common ratio 2. If we have n ... Read More

Calculate Round Trip Time (RTT) in C

Sunidhi Bansal
Updated on 20-Nov-2019 10:59:01

1K+ Views

Given an Url address of any website; the task is to calculate the round trip time of a website.Round Trip Time(RTT) is the total time or the length of a time which is taken to send a signal plus the time taken to receive the acknowledgement of that signal to be received. This time also consist of the propagation times between two points of a signal.An end user can determine his/her round trip time from an IP address by pinging that address.The Round Trip time’ result depends upon the following reasons −The Transmission medium.The presence of Interface in the circuit.Number ... Read More

Change RGB Color Model to HSV Color Model in C

Sunidhi Bansal
Updated on 20-Nov-2019 10:52:39

3K+ Views

Given RGB color range in form of integers; the task is to find its appropriate HSV color by converting the RGB color rangeWhat is RGB color modelRGB color model comprised of three colors Red, Green and Blue. RGB model is a color model which is widely used in the display technologies; it is an additive model in which we add these three colors of with different intensities to produce millions of different colors on a display device.What is HSV color model?HSV color model comprises Hue, Saturation, Value also known as HSB (Hue, Saturation, Brightness).HSV is alternative representation of RGB color ... Read More

Convert a Given Number to Words in C

Sunidhi Bansal
Updated on 20-Nov-2019 10:45:22

12K+ Views

Given a string consisting of numerical values, the task is to covert those given numbers in words.Like we have an input “361”; then the output should be in words i.e, ” Three hundred sixty one”. For the solution of the following problem we have to keep in mind the numbers and places it is in on like ones, tens, thousands etc.The code only support upto 4 digits numbers i.e., 0 to 9999. So the input should be from 0 to 9999.Let us consider 1, 111 so the places will be like −ExampleInput: “1234” Output: one thousand two hundred thirty four ... Read More

Print All Subsets of 1, 2, 3, ..., n without Array or Loop in C

Sunidhi Bansal
Updated on 20-Nov-2019 10:27:55

1K+ Views

Given a positive integer n we have to print all the subsets of a set of {1, 2, 3, 4, … n} without using any array or loops.Like we have given any number say 3 s we have to print all the subset in the set {1, 2, 3} which would be {1 2 3}, {1 2}, {2 3}, {1 3}, {1}, {2}, {3} { }.But we have to do this without using any loop or an array. So, only the recursion is the possible way to solve this type of problem without using any array or a loop.ExampleInput: 3 ... Read More

Check Strength of Password in C++

Sunidhi Bansal
Updated on 20-Nov-2019 10:14:56

7K+ Views

Given a string input containing password characters, the task is to check the strength of the password.The strength of the password is when you tell that the password is whether easily guessed or cracked. The strength should vary from weak, average and strong. To check the strength we have to check the following points −Password must be at least 8 characters long.It must contain 1 lower case alphabet.It must contain 1 uppercase alphabetIt must contain a digitIt must contain a special character like : !@#$%^&*()>= 8))          Print "Strong"       else if ((hasLower || hasUpper) ... Read More

Convert Hexadecimal to Octal in C

Sunidhi Bansal
Updated on 20-Nov-2019 10:05:51

2K+ Views

We are given a Hexadecimal number as string; the task is to convert it to the Octal. To convert a hexadecimal number to octal, we have to −Find the binary equivalent to the hexadecimal number.Convert the binary number to Octal.What are hexadecimal numbersHexadecimal numbers are the numbers which are of base of 16 the numbers vary from 0-9 and from 10 onwards the numbers are represented as A which represents 10, B for 11, C for 12, D for 13, E for 14, and F for 15.To convert hexadecimal number into binary number every number is converted into its binary ... Read More

Matcher.quoteReplacement() Method in Java with Examples

Maruthi Krishna
Updated on 20-Nov-2019 07:43:12

544 Views

The appendReplacement() method of the Matcher class accepts a StringBuffer object and a String (replacement string) as parameters and, appends the input data to the StringBuffer object, replacing the matched content with the replacement string.Internally, this method reads each character from the input string and appends the String buffer, whenever a match occurs it appends the replacement string instead of matched content part of the string to the buffer and, proceeds from the next position of the matched substring.While passing the replacement string to this method if you use “/” or “$” they will not be considered as regular characters ... Read More

Matcher hitEnd() Method in Java with Examples

Maruthi Krishna
Updated on 20-Nov-2019 07:38:51

115 Views

The java.util.regex.Matcher class represents an engine that performs various match operations. There is no constructor for this class, you can create/obtain an object of this class using the matches() method of the class java.util.regex.Pattern.The hitEnd() method verifies whether the end of the input data reached during the previous match if so, it returns true else false. If this method returns true it indicates that more input data might change the result of the match.For example, if you are trying to match the last word of an input string to you using the regex “you$” and if your 1st input line ... Read More

Use Anchoring Bounds Method in Java with Examples

Maruthi Krishna
Updated on 20-Nov-2019 07:32:57

160 Views

The java.util.regex.Matcher class represents an engine that performs various match operations. There is no constructor for this class, you can create/obtain an object of this class using the matches() method of the class java.util.regex.Pattern.The anchoring bounds are used to match the region matches such as ^ and $. By default, a matcher uses anchoring bounds.The useAnchoringBounds() method of this class method accepts a boolean value and, if you pass true to this method the current matcher uses anchoring bounds and if you pass false to this method it uses non-anchoring bounds.Example 1import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Trail ... Read More

Advertisements