Found 1401 Articles for C

Area of a Circular Sector?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

652 Views

A circular sector also known as circle sector / sector of a circle is the portion of the circle that is inscribed by between 2 radii. This area is enclosed between two radii and an arc. To find the area inscribed we need to find the angle that is between the two radii. The total area is equal to 360o of angle. To find the area for an angle we will multiply the area by θ/360. This given the area of section inscrible.Where θ is the angle between the two radii in degree.Area of a sector of a circle = ... Read More

Area of a circle inscribed in a regular hexagon?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

3K+ Views

The circle inscribed in a regular hexagon has 6 points touching the six sides of the regular hexagon.To find the area of inscribed circle we need to find the radius first. For the regular hexagon the radius is found using the formula, a(√3)/2.Now area of the circle inscribed is 3πa*a/4SampleSide of hexagon − 4Area = 37.68Example Code Live Demo#include int main(void) {    int a = 14;    float pie = 3.14;    float area = (float)(3*a*a*pie/4);    printf("The area of circle inscribed in the hexagon of side %d is %f", a, area);    return 0; }OutputThe area of circle ... Read More

C program to find Decagonal Number?

karthikeya Boyini
Updated on 30-Jun-2020 15:28:18

61 Views

A decagonal number is a figurate that was derived using the concept of triangular numbers and square numbers. This extension of number pattern is created using non-rotationally symmetrical numbers. This nested decagon oriented number is given by the number of dots in the number of nested decagons that are created. For example, for 3rd decagonal number 3 decagonal figures are nest each with iX time the number of sides in the decagon. As shown in figure −Side in 1st Outer figure = 30 Side in 2nd Outer figure = 20 Side in inner figure = 10 Sides common in all = 6+2 Total = 30+20+10-(6+2) ... Read More

Average of even numbers till a given even number?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

3K+ Views

To find the average of even numbers till a given even number, we will add all the even number till the given number and t count the number of even numbers. Then divide the sum by the number of even numbers.ExampleAverage of even numbers till 10 is 6 i.e.2 + 4 + 6 + 8 + 10 = 30 => 30/ 5 = 6There are two methods for calculating the average of even number till n which is an even number.Using LoopsUsing FormulaProgram to find the average of even number till n using loopsTo calculate the average of even numbers ... Read More

Average of odd numbers till a given odd number?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

3K+ Views

The average of odd numbers till a given odd number is a simple concept. You just need to find odd numbers till that number then take their sum and divide by the number.If average of odd number till n is to be found. Then we will find odd numbers from 1 to n add then divide it by the number of odd number.ExampleAverage of odd number till 9 is 5 i.e.1 + 3 + 5 + 7 + 9 = 25 => 25/5 = 5There are two methods for calculating the average of odd number till n which is an ... Read More

Average of Squares of Natural Numbers?

Sharon Christine
Updated on 30-Jul-2019 22:30:26

2K+ Views

The average of the square of Natural Number is calculated by adding all the squares up to n natural numbers and then dividing it by the number.SampleAverage of square of first 2 natural numbers is 2.5 ,12 + 22 = 5 => 5/2 = 2.5.There are two methods for calculating this is programming −Using LoopsUsing FormulaCalculating average of square of natural numbers using loopsThis logic works by finding the squares of all natural numbers. By loop from 1 to n finding square of each and adding to the sum variable. Then dividing this sum by n.Program to find the sum ... Read More

Power Function in C/C++

Sharon Christine
Updated on 30-Jul-2019 22:30:26

842 Views

Power function is used to calculate the power of the given number.The pow function find the value of a raised to the power b i.e. ab.Syntaxdouble pow(double a , double b)It accepts a double integers as input and output a double integer as output. It pow() function is defined in math.h package.If you pass an integer to the power function, the function converts it into double data type. But there's an issue with this, sometimes this conversion might store this as a lower double. For example, if we pass 3 and is converted as 2.99 then the square is 8.99940001 ... Read More

Area of the largest triangle that can be inscribed within a rectangle?

Sharon Christine
Updated on 30-Jul-2019 22:30:26

216 Views

A rectangle is a quadrilateral that has opposite side equal and parallel. The adjacent side are at 90o. And a triangle is a closed figure with three sides.The largest triangle inscribed within a rectangle. Has its base equal to the length of the rectangle and height of the triangle is equal to the breadth of the rectangle.Area = (½)*l*bArea of largest triangle inscribed in a rectangle = (½)*l*bProgram to calculate the area of the largest triangle inscribed in a rectangle −Example Code#include int main(void) {    int l = 10, b = 9;    float area ;    area ... Read More

1’s and 2’s complement of a Binary Number?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

4K+ Views

Binary Number is expressed in base 2. It uses only two digits ‘0’ and ‘1’. Each digit in a binary number is a bit.Sample binary Number − 01000101111’s ComplementOne's complement of a binary number is obtained by reversing the digits of the binary number i.e. transforming 1 with 0 and 0 with 1.Example1’s Complement of 101100 = 0100112’s ComplementTwo’s complement of a binary number is obtained by adding one to the one’s complement of a binary number i.e. 1’s complement + 1.Example2’s complement of 101101 is 010011.Example CodeCode to find One’s and two’s complement −#include #include using namespace std; ... Read More

Sum of the first N Prime numbers

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

3K+ Views

The program to print the sum of the first N prime numbers uses the method to find n prime numbers and then add them to find the sum. This sum is saved to an integer that outputs the sum .The code takes a number checks it for prime, if it is prime then adds it to the sum variable. Till n prime number it does the same and then after that it prints the sum.Example Code Live Demo#include int isprime(int j) {    int count=0;    for(int i = 2 ; i

Advertisements