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

What is the meaning of 2d in c?

0 Answers  


what is the meaning of 'c' language

3 Answers  


How do I access command-line arguments?

2 Answers   Bosch, Wipro,


what is the output of below pgm? void main() { int i=0; if(i) printf("pass"); else printf("fail"); }

4 Answers  


count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

0 Answers  


What is the g value paradox?

0 Answers  


What is array within structure?

0 Answers  


i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....

0 Answers   RBI,


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

0 Answers  


helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.

3 Answers  


i want to job in your company, so how it will be possible.

3 Answers   TCS,


Write a program to interchange two variables without using the third variable?

17 Answers   Accenture, College School Exams Tests, Infotech,


Categories