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
Give basis knowledge of web designing ...
Why shouldn’t I start variable names with underscores?
write a program to create a sparse matrix using dynamic memory allocation.
Do pointers store the address of value or the actual value of a variable?
What functions are in conio h?
What does c mean in basketball?
What is use of integral promotions in c?
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
What's a good way to check for "close enough" floating-point equality?
Write a program in c to replace any vowel in a string with z?
What is the difference between near, far and huge pointers?
Explain how are 16- and 32-bit numbers stored?
Which built-in library function can be used to match a patter from the string?
What is putchar() function?
What is the use of structure padding in c?