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
Explain the red-black trees?
How to set file pointer to beginning c?
Are there constructors in c?
What is a pointer in c plus plus?
Who developed c language?
How can I remove the trailing spaces from a string?
Define Array of pointers.
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
Which is the best website to learn c programming?
Do pointers need to be initialized?
What are c header files?
Can include files be nested?
What is a newline escape sequence?
What is structure in c language?