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 / 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 |
Post New Answer View All Answers
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
What is the use of pragma in embedded c?
Is it possible to initialize a variable at the time it was declared?
What is difference between array and pointer in c?
The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.
The statement, int(*x[]) () what does in indicate?
How to delete a node from linked list w/o using collectons?
What is the difference between functions getch() and getche()?
what is the syallabus of computer science students in group- 1?
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
Find MAXIMUM of three distinct integers using a single C statement
What are the keywords in c?
If the size of int data type is two bytes, what is the range of signed int data type?
Can you subtract pointers from each other? Why would you?
Is exit(status) truly equivalent to returning the same status from main?