A program to find sum of series between two integers numbers illustrating for loop in C - language
Working example
/**
* Sum Of Series Between Start To End Values
* Using For Loop
*/
#include <stdio.h>
int main()
{
int i, start, end, result = 0;
printf(" Enter start & end number: ");
scanf("%d %d", &start, &end);
printf("\n Start value : %d", start);
printf("\n End value : %d", end);
for (i = start; i <= end; i += 1)
{
//printf("\n I : %d", i);
//printf("\n Result B4 adding : %d", result);
result = result + i;
//printf("\n Result : %d", result);
}
printf("\n Sum of series : %d", result);
printf("\n");
return 0;
}
Output
Enter start & end number: 12 24
Start value : 12
End value : 24
Sum of series : 234 Related Articles
Deepen your understanding with these curated continuations.
Program 5 min read
Identify whether the number is Even or Odd in C-language
Learn how to check if a number is even or odd in C using the modulo operator. Includes a flowchart, logic explanation, and complete source code.
Vishnu
Program 5 min read
Print Upside Down Triangle Pattern in C
Master C pattern programming with this tutorial on printing an upside-down triangle. Includes fuzzy logic and nested loop implementations for developers.
Vishnu
Program 5 min read
Calculate Factorial in C Using a For Loop
Learn how to calculate the factorial of an integer in C using a for loop. Includes a step-by-step algorithm and complete working code examples.
Vishnu