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 / na
#include<stdio.h>
main()
{
int i;
int sum=0;
for(i=2;i<=30;i++)
{
if(i%2==0)
{
sum=sum+i;
}
}
printf("%d",sum);
return 0;
}
| Is This Answer Correct ? | 3 Yes | 4 No |
Post New Answer View All Answers
What is c programming structure?
Is array a primitive data type in c?
How many main () function we can have in a project?
What does int main () mean?
A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?
How do we open a binary file in Read/Write mode in C?
Are negative numbers true in c?
Can a local variable be volatile in c?
Why is c fast?
How can I find the modification date and time of a file?
What is a lookup table in c?
What is variables in c?
How will you write a code for accessing the length of an array without assigning it to another variable?
What is a ternary operator in c?
how logic is used