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
Explain how can a program be made to print the name of a source file where an error occurs?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
What is the description for syntax errors?
Differentiate between static and dynamic modeling.
Can the sizeof operator be used to tell the size of an array passed to a function?
Write a program to reverse a string.
Tell me about low level programming languages.
In C programming, what command or code can be used to determine if a number of odd or even?
What is the value of uninitialized variable in c?
What are different types of pointers?
What is the difference between memcpy and memmove?
Explain what is the concatenation operator?
What is the difference between local variable and global variable in c?
Can we change the value of static variable in c?
How can you determine the size of an allocated portion of memory?