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 / rukmanee
#include<stdio.h>
#include<conio.h>
main()
{
int i;
int sum=0;
clrscr();
for(i=2;i<=30;i++)
{
if(i%2==0)
{
sum=sum+i;
}
}
printf("%d",sum);
getch();
}
output:240
| Is This Answer Correct ? | 5 Yes | 5 No |
Post New Answer View All Answers
Can you define which header file to include at compile time?
Where are some collections of useful code fragments and examples?
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What are header files why are they important?
Why we use stdio h in c?
how many errors in c explain deply
What are the types of bitwise operator?
The file stdio.h, what does it contain?
How can I find out how much free space is available on disk?
What is the use of structure padding in c?
Can we declare a function inside a function in c?
The difference between printf and fprintf is ?
What is the difference between the = symbol and == symbol?
What is an array in c?
Why use int main instead of void main?