Write a c code segment using a for loop that calculates and
prints the sum of the even integers from 2 to 30, inclusive?

Answer Posted / vignesh1998i

#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,sum=0;
clrscr();
printf("enter the starting point :");
scanf("%d",&m);
printf("ending point :");
scanf("%d",&n);
for(int i=m;i<=n;i+=2)
sum+=i;printf("\n\nthe sum is %d:",sum);
getch();
}


thank u

Is This Answer Correct ?    6 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

1735


Can you explain the four storage classes in C?

650


show how link list can be used to repersent the following polynomial i) 5x+2

1693


What is bash c?

568


There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?

834






What is local and global variable in c?

627


In a header file whether functions are declared or defined?

639


What is a static variable in c?

678


How do you declare a variable that will hold string values?

678


how logic is used

1508


#include { printf("Hello"); } how compile time affects when we add additional header file .

1437


What is a loop?

564


What is the difference between text and binary i/o?

606


can we implement multi-threads in c.

679


What is a function in c?

586