Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is c programming structure?

1191


Is array a primitive data type in c?

1055


How many main () function we can have in a project?

1109


What does int main () mean?

1021


A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?

2314


How do we open a binary file in Read/Write mode in C?

1239


Are negative numbers true in c?

1061


Can a local variable be volatile in c?

989


Why is c fast?

1056


How can I find the modification date and time of a file?

1083


What is a lookup table in c?

1118


What is variables in c?

1050


How will you write a code for accessing the length of an array without assigning it to another variable?

1044


What is a ternary operator in c?

1120


how logic is used

1966