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


Please Help Members By Posting Answers For Below Questions

Explain how can a program be made to print the name of a source file where an error occurs?

678


what is a NULL Pointer? Whether it is same as an uninitialized pointer?

753


What is the description for syntax errors?

606


Differentiate between static and dynamic modeling.

611


Can the sizeof operator be used to tell the size of an array passed to a function?

608






Write a program to reverse a string.

629


Tell me about low level programming languages.

636


In C programming, what command or code can be used to determine if a number of odd or even?

618


What is the value of uninitialized variable in c?

562


What are different types of pointers?

556


What is the difference between memcpy and memmove?

595


Explain what is the concatenation operator?

617


What is the difference between local variable and global variable in c?

679


Can we change the value of static variable in c?

554


How can you determine the size of an allocated portion of memory?

734