Navigate back to the homepage

A Program to find sum of series from starting number to ending number using for loop in C

Vishnu Damwala
March 2nd, 2020 · 1 min read

A tutorial to finding factorial for integer data-type using for loop in C - language

Working example:

1/**
2 * Sum Of Series Between Start To End
3 * Values Using For Loop
4 */
5#include <stdio.h>
6int main()
7{
8 int i, start, end, result = 0;
9 printf(" Enter start & end number: ");
10 scanf("%d %d", &start, &end);
11 printf("\n Start value : %d", start);
12 printf("\n End value : %d", end);
13
14 for (i = start; i <= end; i += 1)
15 {
16 //printf("\n I : %d", i);
17 //printf("\n Result B4 adding : %d", result);
18 result = result + i;
19 //printf("\n Result : %d", result);
20 }
21 printf("\n Sum of series : %d", result);
22 printf("\n");
23 return 0;
24}

Output:

1Enter start & end number: 12 24
2
3Start value : 12
4End value : 24
5Sum of series : 234

More articles from MeshWorld

A Program to display factorial of specified number using for loop in C

A Program to display factorial of specified number using for loop in C.

March 1st, 2020 · 1 min read

How to find the length of a string using strlen() in C

C program to find length of a string, for e.g, length of "East or West INDIA is best" is 26 (including space and excluding null character).

February 25th, 2020 · 1 min read
© 2017–2020 MeshWorld
Link to $https://twitter.com/meshworldindiaLink to $https://facebook.com/meshworldindiaLink to $https://instagram.com/meshworld.india/