Found 1401 Articles for C

Sum of the first N terms of the series 5,12, 23, 38…. in C Programming

sudhir sharma
Updated on 09-Aug-2019 11:30:37

91 Views

To find the sum of the given series, we will analyze the series and try to get some traits that show it is known series or at least is a combination of 2 - 3 series. the given series is 5, 12, 23, 38…We have to find the sum of the series for any value of nFor exampleFor n = 3 Sum = 40.On analyzing the given series, you will find that this series is Quadratic series. In quadratic series, the difference of the numbers is in an arithmetic progression( increase by definite number)So we can directly use the formula ... Read More

Sum of the first N terms of the series 2,10, 30, 68,…. in C programming

sudhir sharma
Updated on 09-Aug-2019 11:28:04

128 Views

To find the sum of this series, we will first analyze this series.The series is:The given series is 2, 10, 30, 68…For exampleFor n = 6 Sum = 464On analysis of the given series, you will see that the series is the addition of two series first one is the series of n natural numbers and the second is the cube of n natural numbers this means the series can be split as:2, 10 , 30 ,68 = (1+13) , (2+23), (3 + 33), ( 4 + 43)so we can write the sum of the series as :sum = 2 ... Read More

Sum of the first N terms of the series 2, 6, 12, 20, 30…. in c programming

sudhir sharma
Updated on 09-Aug-2019 11:21:01

254 Views

To find the sum of this series, we will first analyze this series.The series is: 2,6,12,20,30…ExampleFor n = 6 Sum = 112 On analysis, (1+1),(2+4),(3+9),(4+16)... (1+12), (2+22), (3+32), (4+42), can be divided into two series i.e. s1:1,2,3,4,5… andS2: 12,2,32,....Find the sum of first and second using mathematical formulaSum1 = 1+2+3+4… , sum1 = n*(n+1)/2 Sum2 = 12+22+32+42… , sum1 = n*(n+1)*(2*n +1)/6Example#include int main() {    int n = 3;    int sum = ((n*(n+1))/2)+((n*(n+1)*(2*n+1))/6);    printf("the sum series till %d is %d", n,sum);    return 0; }OutputThe sum of series till 3 is 20

Sum of first n natural numbers in C Program

sudhir sharma
Updated on 01-Jul-2020 11:08:28

1K+ Views

The concept of finding the sum of sum of integers is found such that first, we will find the sum of numbers up to n and then add all the sums to get a value which will be the sum of sum which is our desired sum.For this problem, we are given a number n up to which we have to find the sum of the sum. Let's take an example to find this sum.n = 4Now we will find the sum of numbers for every number from 1 to 4 :Sum of numbers till 1 = 1 Sum of ... Read More

C Program for simple interest?

sudhir sharma
Updated on 09-Aug-2019 07:20:30

514 Views

Simple Interest is the product of principal amount, rate of interest and the time duration (in years) by 100.Example,Input − p=5, r=4, t=5Output − 1Explanation: Simple Interest = (Principal Amount * Rate of Interest * Number of years) / 100SI= 5*4*5/100 = 1Example#include #include using namespace std; int main() {    //principle amount    float p = 5;    //time    float r = 4;    //rate in years    float t = 5;    // Simple interest    float SI = 0;    SI =(p * t * r) / 100;    printf("Simple Interest = %f ",SI);    return 0; }OutputSimple Interest = 1.0000

Area of a n-sided regular polygon with given Radius in C Program?

sudhir sharma
Updated on 13-Aug-2019 08:27:29

291 Views

A polygon is a ‘n’ sided closed figure.N sided polygon means a polygon with n equal sides. The radius of a polygon is distance between center and vertex.In the figure we can see that the whole polygon can be divided into n equal polygonWe know, area of the triangle = (base * height)/2Area of the small triangle using trigonometric logic, area = r2*sin(t)cos(t) = (r2*sin(2t))/2So, area of the polygon:Area = n * (area of one triangle)= n*r2*sin(2t)/2 = n*r2*sin(360/n)/2Example#include #include int main() {    float r = 4 n = 12;    float area = ((r * r ... Read More

Area of a leaf inside a square in C Program?

sudhir sharma
Updated on 09-Aug-2019 07:07:47

176 Views

To find the area of leaf inside a square, we need to split it into parts and find the area of parts and then add the areas to find the area of leaf.To calculate the area we are splitting the leaf into two parts.To find the area of 1st part AECA, we will find the area of quad circle AECDA and subtract the area of triangle ACDA from it.area of a Quadrant = 1⁄4 *(π*r2) whereπ = 22/7 or 3.141.area of a right angle triangle= 1⁄2*B*H = ½ a2Example#include #define PI 3.14159265 int main() {    float a = 12.3; ... Read More

C Program for Area of a square inscribed in a circle which is inscribed in a hexagon?

sudhir sharma
Updated on 09-Aug-2019 06:57:01

144 Views

Given, A square that is inscribed within a circle that is inscribed in a regular hexagon and we need to find the area of the square, for that we need to find the relation of the side of square and the side of the hexagon.The mathematical formula for the radius of circle inscribed within the hexagon is, r=A√3/2Since, the diagonal of square is equal to diameter of the circle, so the relation between the radius and side is, a=√rBased on the side of hexagon, a = √3A/√2So, Area of the Square, Area=a2 = (√3A/√2)2Example#include #include int main() { ... Read More

Area of decagon inscribed within the circle in C Program?

sudhir sharma
Updated on 09-Aug-2019 06:43:58

217 Views

A regular decagon is a ten sided polygon with all sides and angles equal. And here we need to find the area of a decagon that is inscribed inside a circle using the radius of the circle r, Mathematical formula for the side of the decagon inscribed in the circle, a = r√(2-2cos36o)(Using cosine rules)Formula for finding area of decagon, Area = 5*a2*(√5+2√5)/2 Area = 5 *(r√(2-2cos36))^2*(√5+2√5)/2 Area = (5r2*(3-√5)*(√5+2√5))/4Using this formula in a program, Example#include #include int main() {    float r = 8;    float area = (5 * pow(r, 2) * (3 - sqrt(5))* (sqrt(5) ... Read More

Area of hexagon with given diagonal length in C Program?

sudhir sharma
Updated on 09-Aug-2019 06:40:03

841 Views

A Hexagon is a closed figure of 6 side and a regular hexagon is the one which has all six sides equal and angle equal. For finding the area of hexagon, we are given only the length of its diagonal i.e d.The interior angles of Hexagon are of 120 degrees each and the sum of all angles of a Hexagon is 720 degrees.The formula to find the area of hexagon with side length a, Area = (3a2 √3) / 2.Since all sides are of same size and angle is 120 degrees, d = 2a or a = d/2By putting the ... Read More

Advertisements