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
What is spaghetti programming?
#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }
Explain what is the general form of a c program?
Is flag a keyword in c?
What is pass by reference in c?
Is there a way to jump out of a function or functions?
What is array of structure in c?
Why header file is used in c?
In which language linux is written?
Who invented bcpl language?
How can I handle floating-point exceptions gracefully?
What is difference between structure and union in c?
Explain how can type-insensitive macros be created?
What are c header files?
Is that possible to add pointers to each other?