Sum of ALL Numbers in the Given Range
Source Code
#include <stdio.h>
void main()
{
int index, begno, endno, sum = 0;
printf("Program for sum of all numbers in the given range\n");
printf("Enter Beg. No.: ");
scanf("%d", &begno);
printf("Enter End. No.: ");
scanf("%d", &endno);
index = begno;
for(; index <= endno; index ++)
sum = sum + index;
printf("The sum of even numbers between %d and %d is: %d", begno, endno, sum);
}
Output
Program for sum of all numbers in the given range
Enter Beg. No.: 1
Enter End. No.: 100
The sum of even numbers between 1 and 100 is: 5050
#include
উত্তরমুছুনmain()
{
int i,n,sum=0;
printf("Enter the number for sum\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum+=i;
}
printf("The sum of all numbers:%d",sum);
return 0;
}
#include"stdio.h"
উত্তরমুছুনmain(){
int i,s,n,sum=0;
printf("Enter start num :\n");
scanf("%d",&s);
printf("\nEnter end num :\n");
scanf("%d",&n);
for(i=s;i<=n;i++){
sum+=i;
}
printf("Sum of given range is :%d",sum);
}
#include
উত্তরমুছুনmain()
{
int a,b,i,sum=0;
printf("The start value : ");
scanf("%d",&a);
printf("\nThe end value : ");
scanf("%d",&b);
do
{
sum+=a;
a++;
}
while(a<=b);
printf("\nSum of all numbers in given range : %d\n",sum);
}
#include
উত্তরমুছুনmain()
{
int a,i,b,c,sum=0;
scanf("%d",&a);
for(i=0;i<=4;i++)
{
if (a!=0)
{
b=a%10;
a=a/10;
c=b;
sum+=b;
}
}
printf("%d",sum);
}
#include
উত্তরমুছুনmain()
{
int g,h,sum=0;
printf("enter the number for sum:\n");
scanf("%d",&g);
for(g=1;g<=h;g++)
{
sum+=g;
}
printf("the sum of all numbers,%d",sum);
return 0;
}
#include
উত্তরমুছুনmain()
{
int a,b,sum;
printf("enter the start number:\n");
scanf("%d",&a);
printf("enter the end number:\n");
scanf("%d",&b);
for(a=sum;a<=b;a++)
sum+=a;
printf("sum of given renge:%d",sum);
}
#include
উত্তরমুছুনmain()
{
int a,b,i,sum=0;
printf("Enter the value of a\n");
scanf("%d",&a);
printf("Enter the value of b\n");
scanf("%d",&b);
for(i=a;i<=b;i++)
{
sum=sum+i;
}
printf("%d",sum);
}
#include
উত্তরমুছুনint main()
{
int i, s, n, sum = 0;
printf("Enter Launch.: ");
scanf("%d", &s);
printf("Enter Terminate.: ");
scanf("%d", &n);
i = s;
for(; i <= n; i ++)
sum = sum + i;
printf("The sum of even numbers between %d and %d is: %d", s, n, sum);
}
#include
উত্তরমুছুনmain()
{
int a,b,i,sum=0;
printf("The start value : ");
scanf("%d",&a);
printf("\nThe end value : ");
scanf("%d",&b);
do
{
sum+=a;
a++;
}
while(a<=b);
printf("\nSum of all numbers in given range : %d\n",sum);
}
include
উত্তরমুছুনmain()
{
int i,j,k,sum=0;
printf("The start number : ");
scanf("%d",&i);
printf("\nThe end number : ");
scanf("%d",&j);
while (i<=j)
{
if(i%2==0)
sum+=i;
i++;
}
printf("\nThe sum of even is : %d\n",sum);
}