C program to print all pairs of two even numbers whose sum is equal to 40. Also draw
a flowchart for the same.
Answers
Answered by
0
Answer:
Where is carbon dating method used?
Explanation:
Carbon dating is used by archeologists to date trees, plants, and animal remains; as well as human artifacts made from wood and leather; because these items are generally younger than 50,000 years.
Answered by
0
Answer:
#include <stdio.h>
int main() {
int i,j,sum=0;
for(i=0;i<=40;i=i+2)
{
for(j=0;j<=40;j=j+2)
{
sum=i+j;
if(sum==40)
printf("(%d" "," "%d)\n", i,j);
}
}
return 0;
}
Explanation:
- We first declare two variables i and j as the two even numbers and a variable sum to store the sum of i and j.
- All the three variables declared are of the integer data type.
- Next we run a pair of nested for loops.
- The outer for loop keeps track of the first even number. We start from i = 0 and go up to i = 40 by incrementing the value of i by 2 after every iteration.
- The inner for loop keeps track of the second even number. We start from i = 0 and go up to i = 40 by incrementing the value of i by 2 after every iteration.
- For every value of i, the inner for loop is run from j = 0 to 40.
- For every pair of i and j, we calculate the sum and check if it is equal to 40 or not.
- If the sum is equal to 40, the numbers are printed.
- If the sum is not equal to 40, the next pair of numbers are tested.
- Once all the possible combinations are checked, the program is terminated.
The flowchart for the given code is as follows:
#SPJ3
Attachments:
Similar questions