The document contains code snippets and explanations for various algorithms and mathematical formulas including calculating sums using different loops, printing even and odd numbers, arranging terms in descending order, Bhaskara's formula, the trapezium formula, and selection sort. It provides code examples to calculate sums of series using for, while, and do-while loops, and algorithms for sorting arrays and arranging terms in descending order.
Get The Student Details Like Name, Dept, m1, m2, m3. Find The Average and Grade of The Student (O, A, B, C) - Using Switch Case Convert The Grade Into O-Excellent, A - Good, B-Average, C-Fair
The document contains code snippets and explanations for various algorithms and mathematical formulas including calculating sums using different loops, printing even and odd numbers, arranging terms in descending order, Bhaskara's formula, the trapezium formula, and selection sort. It provides code examples to calculate sums of series using for, while, and do-while loops, and algorithms for sorting arrays and arranging terms in descending order.
The document contains code snippets and explanations for various algorithms and mathematical formulas including calculating sums using different loops, printing even and odd numbers, arranging terms in descending order, Bhaskara's formula, the trapezium formula, and selection sort. It provides code examples to calculate sums of series using for, while, and do-while loops, and algorithms for sorting arrays and arranging terms in descending order.
The document contains code snippets and explanations for various algorithms and mathematical formulas including calculating sums using different loops, printing even and odd numbers, arranging terms in descending order, Bhaskara's formula, the trapezium formula, and selection sort. It provides code examples to calculate sums of series using for, while, and do-while loops, and algorithms for sorting arrays and arranging terms in descending order.
printf("Enter the limit of the series: "); scanf("%d", &limit);
printf("Enter the common difference: ");
scanf("%d", &common_diff);
printf("\nUsing for loop:\n");
for (term = 1; term <= limit; term++) { sum += term * common_diff; } printf("Sum of the series: %d\n", sum); //sum using while-loop printf("\nUsing while loop:\n"); term = 1; sum = 0; while (term <= limit) { sum += term * common_diff; term++; } printf("Sum of the series: %d\n", sum); //sum using do-while loop printf("\nUsing do-while loop:\n"); term = 1; sum = 0; do { sum += term * common_diff; term++; } while (term <= limit); printf("Sum of the series: %d\n", sum); //printing even numbers for(i=1; i<n; i++) //n is input { if(i%2 == 0) { printf(“%d”, n); } }
//printing uneven/odd numbers
for(i=1; i<n; i+=2) //n is input { printf(“%d”, n); }
//finding a term in a series
For arithmetic series: a+(n-1)d For geometric series: a x r^(n-1)
//arranging 3 terms in descending order with a as greatest term
Get The Student Details Like Name, Dept, m1, m2, m3. Find The Average and Grade of The Student (O, A, B, C) - Using Switch Case Convert The Grade Into O-Excellent, A - Good, B-Average, C-Fair