1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alukav5142 [94]
2 years ago
6

Write a function that receives two numbers, m and n and calculates and displays the sum of the integers from m to n. For example

, if the arguments are m = 3 and n = 7, the function should calculate 3 + 4 + 5 + 6 + 7
Computers and Technology
1 answer:
Evgesh-ka [11]2 years ago
7 0

Answer:

The program to this question as follows:

Program:

//header file

#include <stdio.h> //defining header file

void inc(int m,int n) //defining method inc

{

   int sum, i; //declaring variable

   sum=m; //holding value of m variable

   for(i=++m;i<=n;i++) //loop for calculate number between given range  

   {

   sum=sum+i; //adding value

   }

   printf("sum of the integer is : %d",sum);//print value

}

int main() //defining method

{

   int m,n; //defining integer variable

   printf("Enter m value: "); //message

   scanf("%d",&m); //input value by user in variable

   printf("Enter n value: "); //message

   scanf("%d",&n);//input value by user in variable

   inc(m,n); //calling method

   return 0;

}

Output:

Enter m value: 3

Enter n value: 7

sum of the integer is :25

Explanation:

In the above code, an "inc" function is declared, that accepts integer parameters that are "m and n", inside the method two integer variable "sum and i" is declared, which is used in the loop.

  • The loop uses the user parameter to count value and uses the sum variable to calculate there sum.
  • In the main method, two integer variable n and m are declared, which take value from the user end, and at the last, we call the inc method, that prints sum value.
You might be interested in
Which of these engine components forms a tight seal between the piston and the cylinder and is necessary for proper engine opera
TEA [102]
<h2>Piston rings help form a tight seal between the piston and cylinder.   Answer is A. Piston ring</h2>
5 0
3 years ago
Read 2 more answers
A typical analog cell phone has a frequency of 850 mhz; a digital phone a frequency of 1950 mhz. compared to the signal from an
Zepler [3.9K]
A higher frequency than the analog cell phone.
5 0
3 years ago
Which of the following is not a key component of a structure?
valentina_108 [34]
D. Enumerations! Because I know that is NOT a leg compentent of a structure
5 0
2 years ago
1. Which markup language adds the ability to use video without requiring the user to download add-ons?
aniked [119]

HTML5

HTML5 has fewer plug-ins like the ability to standardize how audio and video are presented on a Web page. It introduces the <video> element designed to remove the need to install 3rd party add-ons and plug-ins like adobe flash player. It also adds the <audio> element  too that allows pages to smoothly add audio files.

3 0
3 years ago
What is the full form of com​
nignag [31]

The answer is:

Commercial

3 0
3 years ago
Other questions:
  • How do solar cells translate heat energy into mechanical energy
    13·1 answer
  • Mr. Olgesandravich is proctoring students working at their own pace in an online class. He is generating a spreadsheet that show
    15·1 answer
  • Text that does not fit in a cell
    7·1 answer
  • ​For complex models, analysts can choose computer-based modeling tools that use _____, which includes standard shapes and symbol
    10·1 answer
  • What does snap do need the answer now
    10·2 answers
  • Select the correct answer.
    8·2 answers
  • The database must be carefully planned to allow useful data manipulation and report generation.
    10·1 answer
  • Write a program that extracts the last three items in the list sports and assigns it to the variable last. Make sure to write yo
    8·1 answer
  • Identify traits of entrepreneurs. Check all of the boxes that apply.
    11·1 answer
  • If a salesperson were trying to sell this cabin, which word would be best to use to make its size seem most positive?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!