The Problem Statement: Make a simple program that reads one variable named N which is the summation of 4 consecutive even numbers. Print the 4 consecutive even numbers whose summation is N. 12 + 14 + 16 + 18 = 60 Input Format The first line contains an integer T (1 ≤ T ≤ 3). The Second line contains one integer number N (N<=5000). Output Format Output will show the 4 consecutive even integer numbers separated by space in a separate line. Note: Implement it using function. Sample Input Sample Output 3 100 812 4052 22 24 26 28 200 202 204 206 1010 1012 1014 1016 2 452 508 110 112 114 116 124 126 128 130

 The Problem Statement:

Make a simple program that reads one variable named N which is the summation of 4 consecutive even numbers. Print the 4 consecutive even numbers whose summation is N.

12 + 14 + 16 + 18 = 60

 

Input Format

  • The first line contains an integer T (1 ≤ T ≤ 3).

  • The Second line contains one integer number N (N<=5000). 

Output Format

Output will show the 4 consecutive even integer numbers separated by space in a separate line.

 

Note: Implement it using function.

 

Sample Input

Sample Output

3

100

812

4052

22 24 26 28

200 202 204 206

1010 1012 1014 1016

2

452

508

110 112 114 116

124 126 128 130

 




answer:



Here is a function that reads an integer N and prints the four consecutive even integers whose sum is N:

void find_evens(int N) { // Calculate the first even number in the series int first = N / 4 * 2; // Print the four consecutive even numbers printf("%d %d %d %d\n", first, first + 2, first + 4, first + 6); }

This function calculates the first even number in the series by dividing N by 4 and multiplying the result by 2. It then prints the four consecutive even numbers starting from this first number.

For example, if you call find_evens(60), the function will output 12 14 16 18.

To use this function in a program that reads multiple values of N, you can do the following:

#include <stdio.h> // Function prototype void find_evens(int N); int main(void) { // Read the number of test cases int T; scanf("%d", &T); // Read T values of N and find the four consecutive even integers while (T--) { int N; scanf("%d", &N); find_evens(N); } return 0; }

This program reads the number of test cases T and then reads T values of N. For each value of N, it calls the find_evens function to print the four consecutive even integers.

For example, if the input is:

3 100 812 4052

The program will output:

22 24 26 28 200 202 204 206 1010 1012 1014 1016


Post a Comment

0 Comments

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();