make a program to print the sum of first 10 even numbers
Answers
Answered by
0
Answer:
Explanation:
#include <stdio.h>
int main()
{
int i, n;
/* Input upper limit of even number from user */
printf("Print all even numbers till: ");
scanf("%d", &n);
printf("Even numbers from 1 to %d are: \n", n);
/*
* Start loop counter from 1, increment it by 1,
* will iterate till n
*/
for(i=1; i<=n; i++)
{
/* Check even condition before printing */
if(i%2 == 0)
{
printf("%d\n", i);
}
}
return 0;
}
I hope this ans are helpfull plese mark as brainlist
Similar questions
Business Studies,
5 months ago
Geography,
5 months ago
English,
10 months ago
Political Science,
10 months ago