Find Highest Average Marks of Students in MySQL

AmitDiwan
Updated on 04-Oct-2019 06:32:27

1K+ Views

For this, you can use subquery. Let us first create a table −mysql> create table DemoTable (    StudentName varchar(40),    StudentMarks int ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Adam', 56); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Chris', 78); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Adam', 89); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Robert', 98); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Chris', 65); Query OK, 1 ... Read More

Area of Squares Formed by Joining Midpoints Repeatedly in C

sudhir sharma
Updated on 03-Oct-2019 13:24:05

145 Views

Area of a square is equal to the product of sides of the square.We are considering a figure in which the midpoints of sides of each square make another square. And so on until a specific number of squares.This figure shows a square made by joining the midpoints of a square.For this figure the let the side be a, The length of side of inner square will beL2 = (a/2)2 + (a/2)2 L2 = a2(1/4 + 1/4) = a2(1/2) = a2/2 L = a2/ (\sqrt{2}).Area of square2 = L2 = a2/2.For the next square, the area of square 3 = ... Read More

Area of the Biggest Possible Rhombus Inscribed in a Rectangle in C

sudhir sharma
Updated on 03-Oct-2019 13:13:52

294 Views

A rhombus inscribed in a rectangle touches the sides of the rectangle so by this we can infer that the diagonals of the largest inscribed rhombus are equal to the length and breadth of the rectangle.If we have the length(l) and breadth(b) of the rectangle, the length of the diagonal of the largest rhombus inscribed inside it is d1 = l and d2 = b.The area of a rhombus is given by the formula, Area = (d1*d2)/2Putting the values of d1 and d2. We get, Area = (l*b)/2Using this formula we can create a program that calculates the area of ... Read More

Area of a Circle Inscribed in a Rectangle within a Semicircle in C

sudhir sharma
Updated on 03-Oct-2019 13:10:41

2K+ Views

A circle inscribed in a rectangle touches the larger side of the rectangle with its ends i.e. the length is tangent to the circle.A rectangle inscribed in a semicircle touches its arc at two points. The breadth of the rectangle is equal to the diameter of the circle.If R is the radius of semi-circle.Length of the rectangle = √2R/2Breadth of the rectangle = R/√2Radius of biggest circle inscribed isr = b/2 = R/2√2Using this formula we can find the area of this circle inscribed in a rectangle which is inscribed in a semicircle, Area = (π*r2) = π*R/8Example Live Demo#include ... Read More

Anti-Clockwise Spiral Traversal of a Binary Tree in C++

sudhir sharma
Updated on 03-Oct-2019 13:02:36

206 Views

Anti-Clockwise spiral traversal of a binary tree is traversing the elements of a tree in such a way that if traversed they make a spiral but in reverse order. The following figure shows how a anti-clockwise spiral traversal of binary tree.The Algorithm defined for spiral traversal of a binary tree works in the following way −Two variables i and j are initialized and values are equated as i = 0 and j = height of variable. A flag is used to check while section is to be printed. Flag is initially is set of false. A loop working till i ... Read More

Arc Length from Given Angle in C++

sudhir sharma
Updated on 03-Oct-2019 12:58:30

489 Views

An Angle is formed when two rays meet at a point. The point on the plane at which these rays meet is vertex.Arc of a circle is a portion of the circumference that is described by an angle.In this problem, we are given an angle of the circle. And we need to find the length of arc using the given diameter of the circle. For example, Input : Angle = 45° Diameter = 28 Output : Arc = 11ExplanationLength of arc = (circumference) X (angle/360°)= (π * d)*(angle/360°)To make a program that calculates the length of Arc from the given ... Read More

A Product Array Puzzle in C

sudhir sharma
Updated on 03-Oct-2019 12:51:23

369 Views

An array is a container of elements of the same data types. In product array Puzzle, the product of all elements is found.In this Product Array Puzzle, we need to find the product of all elements of the array except element. The condition is that you cannot use the division operator and store this to another array.For solving this we will be creating two products, one for all left elements and one for all right elements. And then adding this left and right products to get the desired products.Example Live Demo#include #include void productfind(int arr[], int n) {    int *left ... Read More

Find x to Convert Fraction a/b to c/d in C++

Ayush Gupta
Updated on 03-Oct-2019 12:30:47

142 Views

In this article, we will be discussing a program to find ΔX which is added to the numerator and denominator both of given fraction (a/b) to convert it to another given irreducible fraction (c/d).For example, let us suppose we have been given with the following values, a = 4 | b = 2 | c = 4 | d = 3then ΔX would be 4 such that (a + ΔX)/(b + ΔX) = 8/6 = 2/3As we know, (a + ΔX)/(b + ΔX) = c/d. Solving this equation for ΔX, we getΔX = (bc - ad) / (d - c)Example Live ... Read More

Find Path Between Two Cells in Matrix Using C++

Ayush Gupta
Updated on 03-Oct-2019 12:28:49

220 Views

In this article, we will be discussing a program to find whether there exists a path between two cells in a given matrix.Let us suppose we have been given a square matrix with possible values 0, 1, 2 and 3. Here, 0 means Blank Wall1 means Source2 means Destination3 means Blank CellThere can only be one Source and Destination in the matrix. The program is to see if there’s a possible path from Source to Destination in the given matrix moving in all four possible directions but not diagonally.Example Live Demo#include using namespace std; //creating a possible graph from given array ... Read More

Check if Two Parallel Lines Contain All Coordinates in C++

Ayush Gupta
Updated on 03-Oct-2019 12:21:59

426 Views

In this article, we will be discussing a program to find whether only two parallel lines can hold all the given coordinates points.For this we will be given an array, such that the coordinates will be (i, arr[i]). Let us suppose we are given an array, arr = {2, 6, 8, 12, 14}Then we can have these points on two parallel lines, the first line containing (1, 2), (3, 8) and (5, 14). The second line having the rest coordinates i.e (2, 6) and (4, 12).This problem can be solved by comparing the slopes of the lines made by the ... Read More

Advertisements