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 / vignesh1998i
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,sum=0;
clrscr();
printf("enter the starting point :");
scanf("%d",&m);
printf("ending point :");
scanf("%d",&n);
for(int i=m;i<=n;i+=2)
sum+=i;printf("\n\nthe sum is %d:",sum);
getch();
}
thank u
| Is This Answer Correct ? | 6 Yes | 5 No |
Post New Answer View All Answers
How can I get the current date or time of day in a c program?
what is the difference between class and unio?
What are the types of macro formats?
Can you please explain the difference between syntax vs logical error?
why we wont use '&' sing in aceesing the string using scanf
Can true be a variable name in c?
Who developed c language?
Why should I use standard library functions instead of writing my own?
How do we open a binary file in Read/Write mode in C?
What is a floating point in c?
How are structure passing and returning implemented?
Differentiate between ordinary variable and pointer in c.
What is file in c preprocessor?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
Explain zero based addressing.