Write a c code segment using a for loop that calculates and
prints the sum of the even integers from 2 to 30, inclusive?

Answers were Sorted based on User's Feedback



Write a c code segment using a for loop that calculates and prints the sum of the even integers fr..

Answer / 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

Write a c code segment using a for loop that calculates and prints the sum of the even integers fr..

Answer / parekh nirav

#include<stdio.h>
#include<conio.h>
void main()
{
int i,no,sum=0;
clrscr();
printf("\n entre the no:-");
scanf("%d",&no);

for(i=2;i<=30;i+1)
{
printf("\n the list is %d",i);
sum=sum+i;
}
printf("\n the sum is %d",sum);
getch();
}

Is This Answer Correct ?    4 Yes 3 No

Write a c code segment using a for loop that calculates and prints the sum of the even integers fr..

Answer / 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

Write a c code segment using a for loop that calculates and prints the sum of the even integers fr..

Answer / na

#include<stdio.h>
main()
{
int i;
int sum=0;
for(i=2;i<=30;i++)
{
if(i%2==0)
{
sum=sum+i;
}
}
printf("%d",sum);
return 0;
}

Is This Answer Correct ?    3 Yes 4 No

Post New Answer

More C Interview Questions

Describe the order of precedence with regards to operators in C.

0 Answers  


Write a c program to demonstrate character and string constants?

0 Answers  


How to add two numbers without using semicolon at runtime

2 Answers  


What is the difference between local variable and global variable in c?

0 Answers  


What is the use of the function in c?

0 Answers  






What is getch() function?

0 Answers  


What is extern storage class in c?

0 Answers  


how to swap two integers 1 and 32767 without using third variable

11 Answers   Microsoft, TCS,


What is a shell structure examples?

0 Answers  


Can stdout be forced to print somewhere other than the screen?

0 Answers  


What is realloc in c?

0 Answers  


I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

0 Answers  


Categories