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


Please Help Members By Posting Answers For Below Questions

I heard that you have to include stdio.h before calling printf. Why?

582


What is wrong with this declaration?

606


Write a program to reverse a given number in c?

589


How can I make sure that my program is the only one accessing a file?

665


What is data type long in c?

617






How can I delete a file?

621


Compare array data type to pointer data type

592


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?

972


What is modeling?

634


What are loops c?

606


Is c procedural or functional?

580


How can I find out how much free space is available on disk?

620


What is meant by high-order and low-order bytes?

644


What does 4d mean in c?

932


What would be an example of a structure analogous to structure c?

570