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
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
What is array within structure?
What is the difference between call by value and call by reference in c?
how logic is used
How can I write a function that takes a format string and a variable number of arguments?
How can you check to see whether a symbol is defined?
What is the meaning of typedef struct in c?
what is bit rate & baud rate? plz give wave forms
Who invented b language?
How can I access an I o board directly?
Can the size of an array be declared at runtime?
What is unsigned int in c?
Why do we use header files in c?
What is scope and lifetime of a variable in c?
write a programming in c to find the sum of all elements in an array through function.