public class sum {
public static void main(String args[]){
int sum=0;
for(int i=1;i<=10;i++){
sum=sum+i;
}
System.out.println(sum);
}
}
Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.
SUM = 0: FOR N = 1 to 100: SUM = SUM + N: Next N: PRINT CHR$(11); "Sum ="; SUM: END
You can use int i; for (i = 10; i <= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.
You can write a simple program in Python to check if m is a multiple of n. Here's a sample code: m = int(input("Enter the first integer (m): ")) n = int(input("Enter the second integer (n): ")) if n != 0 and m % n == 0: print(f"{m} is a multiple of {n}.") else: print(f"{m} is not a multiple of {n}.") This program reads two integers, checks if n is not zero to avoid division by zero, and then uses the modulus operator to determine if m is a multiple of n.
This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.
Algorithm: multiples input: two positive integers, m and n output: print first n multiples of m i = m; for j = 1 to n print i i = i + m; next j
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
write a program to print A to Z on screen in c?
echo 'print a pattern'
Example: start ask the name for each word . print first letter stop
write a program to print the series 1/12+1/22+.........+1/n2 ?
Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.
write a program in C that prompts the user with the following lines: a) Add two integers c) Compare two integers for the larger t) Test an integers for odd or even q) Quit
This is a directive, not a question.
good morning
Yes.
In QBasic, you can display a new line using the PRINT statement. To create a new line, you can simply use an empty PRINT statement. Here’s a simple example: PRINT "This is the first line." PRINT ' This will create a new line. PRINT "This is the third line." This program will display the first line, then move to a new line, followed by the third line.