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
The domain in an email message tells you the
Vsevolod [243]
<span>The domain in an email message tells you the location of the destination.  A domain is a part of an e-mail address after @. Let us say, [email protected], aol.com is the domain. Therefore, the answer is letter B. location of the destination, and as for the case of the given example above, aol.com is called the location of the destination.

Other examples of domain that we commonly came across with:
[email protected] gmail.com
[email protected] yahoo.com
[email protected] msn.com

</span>


6 0
3 years ago
Read 2 more answers
Complete the procedure for adding a contact by selecting the correct term from each drop-down menu.
VARVARA [1.3K]

Answer:

1 new contact 2 save and close

6 0
3 years ago
A keyboard, mouse, and microphone are examples of ________.
kykrilka [37]

Answer:

A keyboard, mouse, and microphone all are examples of <u>peripheral devices.</u>

Explanation:

hope this helps

5 0
2 years ago
Read 2 more answers
Give 15 examples of copyright and trademarks that we come in contact with everyday. (Doesn't hve to be 15 could be 3 or 5) PLEAS
oksano4ka [1.4K]
Roads, trading, Government, water systems,
6 0
2 years ago
Which of the following information is okay to share on social networking site?
zvonat [6]
C. Your hobbies and interests
4 0
3 years ago
Read 2 more answers
Other questions:
  • public interface Displayable { void display(); } public class Picture implements Displayable { private int size; public void inc
    14·1 answer
  • What is the ability for a system to respond to unexpected failures or system crashes as the backup system immediately and automa
    8·1 answer
  • Jason is working on a project that requires him to manage a huge amount of data. The spreadsheet he is working on has data relat
    15·1 answer
  • Define a class called Counter. An object of this class is used to count things so it records a count that is a non-negative whol
    12·1 answer
  • Science Help
    11·1 answer
  • Consider the code fragment below. Show the values stored at each location in memory and as they change while the code executes.
    5·1 answer
  • What is the purpose of a Post Mortem Review? (5 points)
    5·1 answer
  • 45 points!
    10·2 answers
  • Can able to Computer decide its input by itself? How ?​
    15·1 answer
  • HELP ME PLEASE 41 PTS
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!