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
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
What is the difference between int main and void main?
What are the functions to open and close the file in c language?
what will be maximum number of comparisons when number of elements are given?
What is 2 d array in c?
Explain main function in c?
Is there sort function in c?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
What are actual arguments?
Is null valid for pointers to functions?
How can I find out the size of a file, prior to reading it in?
Explain what is wrong with this program statement?
#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??
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
Explain what is gets() function?