Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C Articles - Page 87 of 134
279 Views
The given series 0.6,0 .o6,.... is a geometric progression where each element is the previous element divided by 10. So find the sum of the series we have to apply the sum of GP one formula for r less than 1(r=0.1 in our case).Sum = 6/10 [1- (1/10)n/(1-1/10)] Sum = 6/9 [1- (1/10)n] Sum = 2/3[1- (1/10n)]Example#include #include int main() { int n = 6; float sum = 2*((1 - 1 / pow(10, n)))/3; printf("sum = %f", sum); }Outputsum = 0.666666
1K+ Views
Given is a sequence: 2,22,222,2222….. and we need to find the sum of this sequence. So we have to Go for the mathematical formula that is made to find the sum of the series,The explanation of the formula goes in such a way that -sum =[2+22+222+2222….] sum= 2*[1+11+111+1111….] Sum = 2/9[9+99+999+9999….] sum= 2/9 [10+100+1000+10000+.....] sum = 2/9[10+102+103+104+.....] sum=2/9*[(10n-1-9n)/9]Example#include #include int main() { int n = 3; float sum = 2*(pow(10, n) - 1 - (9 * n))/81; printf("sum is %d", sum); return 0; }Outputsum is 879
507 Views
Sum of n natural numbers that are divisible by 2 or 5 can be found by finding the sum of all natural numbers up to N that is divisible by 2 and sum of all natural numbers up to N that is divisible by 5. Adding these two sums and then subtracting it by the sum of natural numbers up to N that is divisible by 10, this gives us the desired result. This method is an efficient method that can be used to find sum up to large values of n.Some of you must be thinking of using a ... Read More
4K+ Views
A singly linked list is a data structure in which an element has two parts one is the value and other is the link to the next element. So to find the sum of all elements of the singly linked list, we have to navigate to each node of the linked list and add the element's value to a sum variable.For exampleSuppose we have a linked list: 2 -> 27 -> 32 -> 1 -> 5 sum = 2 + 27 + 32 + 1 + 5 = 67.This can be done by using two methods :Method 1 - Using a ... Read More
181 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
230 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
363 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
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
685 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
431 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