First of all we will describe how our program should be working.
After entering number 1 and 5 I want it count 2 + 3 + 4 and return 9. After entering 4 and 9 it should count 5 + 6 + 7 + 8 and return 26. After entering X and X I should get 0. If I enter X and X - 1 I should get and error.
Here is the code of such application:
#include
int main() {
int firstNum, secondNum, sum, tmp;
printf("Please enter first number: ");
scanf("%d", &firstNum);
printf("Please enter second number: ");
scanf("%d", &secondNum);
if (secondNum < firstNum) {
printf("Sorry, second number must be higher than first one.\n");
return 1;
}
sum = 0;
for (tmp = firstNum + 1; tmp < secondNum; tmp++) {
sum += tmp;
}
printf("All numbers between %d and %d sum equals %d\n", firstNum, secondNum, sum);
return 0;
}
Testing:
Please enter first number: 1
Please enter second number: 5
All numbers between 1 and 5 sum equals 9
Please enter first number: 4
Please enter second number: 9
All numbers between 4 and 9 sum equals 26
Write an. Algorthim. To. Find the. Sum. Of. First15 natural. Numbers
#include<stdio.h> main() { int num1; int num2; int a; printf("Enter any two numbers :"); scanf("%d%d",&num1,&num2); for(a=num1;num1<=num2;a++) { if ( a % 2 == 1); { printf("%d",a); } } getch(); }
#includeint main(){int i;for(i=2;i
int sum (int min, int max) {return (max-min+1)*(max+min)/2;}
draw a flowchart to find the biggest number among the 3 numbers
you find out missing numbers in addition by subtracting the numbers that are writen
Combining two or more numbers to find the sum is called addition.
A calculator. Addition.
Add the two numbers and divide by two, or find the number which is halfway between the two numbers.
Add all the numbers together and that's the sum. The sum is the answer.
One numbers 3 times another number.the difference between the numbers 10. Find the numbers.
the numbers between 0 and 1 is 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.10.
VBnet program to find the prime numbers between 100 to 200?
Find the arithmetic average of the two rational numbers. It will be a rational number and will be between the two numbers.
to subtact the two numbers
There exists infinite number of rational numbers between 0 & -1.
it is pretty easy all you do is add the game to the list if it is not already there then once it is inputed you exit out to the list of games and find the game you just inputed once you have done that press the add button on the right side of the device and add the (m) code first and then the ret of the codes it is pretty easy!!!!!!!!!!!!!!!!!!!!!!!