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's the total generic pointer type?

0 Answers  


write a program to display the numbers in the following 4 4 3 3 2 2 1 1 0 1 1 2 2 3 3 4 4

1 Answers  


Can you apply link and association interchangeably?

0 Answers   InterGraph,


How does C++ help with the tradeoff of safety vs. usability?

1 Answers  


Explain bit masking in c?

0 Answers  


What is the difference between i++ and i+1 ?(in terms of memory)

3 Answers   HCL,


What is diffrance between declaration and defination of a variable or function

4 Answers  


Write a program in c to replace any vowel in a string with z?

0 Answers   IBS,


Explain logical errors? Compare with syntax errors.

0 Answers  


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

0 Answers  


int main() { unsigned char a = 0; do { printf("%d=%c\n",a,a); a++; }while(a!=0); return 0; } can anyone please explain me output????

1 Answers  


What is meant by keywords in c?

0 Answers  


Categories