Here we will see the area of a square which in inscribed in one circle and that circle is inscribed in a hexagon. The side of the square is ‘a’. The radius of the circle is ‘r’, and the side of the hexagon is ‘A’. The diagram will be like below.We know that the radius of a circle inscribed in a hexagon is −Also the radius of the circle is half of the diagonal of the square. So −Then we can say −Then the area will be −Example#include #include using namespace std; float area(float A) { //A is ... Read More
Here we will see one interesting problem related to alphanumeric abbreviation of a given string. The string length is less than 10. We will print all alphanumeric abbreviations.The alphanumeric abbreviation is in the form of characters mixed with the digits. The value of that digit is number of characters that are missed. There may be any number of skipped substrings. No two substrings are adjacent to each other. Let us see the algorithm to get the idea.AlgorithmprintAbbreviation(s, index, max, str) −begin if index is same as max, then print str end if add s[index] ... Read More
Rat in a maze is also one popular problem that utilizes backtracking. IA maze is a 2D matrix in which some cells are blocked. One of the cells is the source cell, from where we have to start. And another one of them is the destination, where we have to reach. We have to find a path from the source to the destination without moving into any of the blocked cell. A picture of an unsolved maze is shown below.And this is its solution.To solve this puzzle, we first start with the source cell and move in a direction where ... Read More
For this, you can use LAST_INSERT_ID(). Let us first create a table −mysql> create table DemoTable ( UserId int(6) unsigned zerofill NOT NULL AUTO_INCREMENT, UserAutoIncrement char(100) default null, PRIMARY KEY(UserId) ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+--------+-------------------+ | UserId | UserAutoIncrement | +--------+-------------------+ | 000001 | NULL | +--------+-------------------+ ... Read More
The program takes a string and removes the spaces in it. This is useful when we want to save the space of our The following sample shows how it is done with an explanation.Input: Hello World Output: HelloWorldExplanationTo remove or delete spaces from the string or sentence, you have to ask the user to enter a string. Now start checking for spaces. If space will be found, then start placing the next character from the space to the back until the last character and continue to check for the next space to remove all the spaces present in the stringExample#include ... Read More
The program to find the minimum sum of factors of a number. The logic for solving this problem is, find all the set of factors and adding them. For every set of factors, we will do the same and then compare all of them. Then find all the minimum of these sums.Input: n=12 Output: 7ExplanationFirst find the factors of number n then sum them and try to minimize the sum. Following are different ways to factorize 12 and sum of factors in different ways.12 = 12 * 1 = 12 + 1 = 13 12 = 2 * 6 = ... Read More
In this program, we are going to learn how to find the total number of lines available in a text file using C program?This program will open a file and read the file’s content character by character and finally return the total number of lines in the file. To count the number of lines we will check the available Newline () characters.Input: File "test.text" Hello friends, how are you? This is a sample file to get line numbers from the file. Output: Total number of lines are: 2ExplanationThis program will open a file and read the file’s content ... Read More
Given two numbers dividend and divisor. The task is to write a program to find the quotient and remainder of these two numbers when the dividend is divided by the divisor.In division, we will see the relationship between the dividend, divisor, quotient, and remainder. The number which we divide is called the dividend. The number by which we divide is called the divisor. The result obtained is called the quotient. The number left over is called the remainder.55 ÷ 9 = 6 and 1 Dividend Divisor Quotient RemainderInput: Dividend = 6 Divisor = 2 Output: Quotient = 3, Remainder = ... Read More
Square Matrix A is said to be skew-symmetric if aij=−aji for all i and j. In other words, we can say that matrix A is said to be skew-symmetric if transpose of matrix A is equal to negative of Matrix A i.e (AT=−A).Note that all the main diagonal elements in the skew-symmetric matrix are zero.lets take an example of a matrixA= |0 -5 4| |5 0 -1| |-4 1 0|It is skew-symmetric matrix because aij=−aji for all i and j. Example, a12 = -5 and a21=5 which means a12=−a21. Similarly, this condition holds true ... Read More
Given a number “n” as an input, this program is to find the total number of divisors of n is even or odd. An even number is an integer that is exactly divisible by 2. Example: 0, 8, -24An odd number is an integer that is not exactly divisible by 2. Example: 1, 7, -11, 15Input: 10 Output: EvenExplanationFind all the divisors of the n and then check if the total number of divisors are even or odd. To do this find all divisor and count the number and then divide this number by 2 to check if it is ... Read More
 
 Data Structure
 Data Structure Networking
 Networking RDBMS
 RDBMS Operating System
 Operating System Java
 Java MS Excel
 MS Excel iOS
 iOS HTML
 HTML CSS
 CSS Android
 Android Python
 Python C Programming
 C Programming C++
 C++ C#
 C# MongoDB
 MongoDB MySQL
 MySQL Javascript
 Javascript PHP
 PHP 
		 
		