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


Please Help Members By Posting Answers For Below Questions

If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402

3253


What is the difference between int main and void main?

580


What are the functions to open and close the file in c language?

597


what will be maximum number of comparisons when number of elements are given?

1413


What is 2 d array in c?

562






Explain main function in c?

632


Is there sort function in c?

581


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

922


What are actual arguments?

652


Is null valid for pointers to functions?

616


How can I find out the size of a file, prior to reading it in?

630


Explain what is wrong with this program statement?

626


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1547


Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250

1513


Explain what is gets() function?

639