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
I heard that you have to include stdio.h before calling printf. Why?
What is wrong with this declaration?
Write a program to reverse a given number in c?
How can I make sure that my program is the only one accessing a file?
What is data type long in c?
How can I delete a file?
Compare array data type to pointer data type
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
What is modeling?
What are loops c?
Is c procedural or functional?
How can I find out how much free space is available on disk?
What is meant by high-order and low-order bytes?
What does 4d mean in c?
What would be an example of a structure analogous to structure c?