the following is C code, should work well enough. If not, you should get the general idea.
int counter;
for (int i=1;i<10;i++)
{
println("Enter a number: ");
cin << counter;
}
println("Total, %i", counter);
int i; for (i=10; printf ("%d\n", i); i--);
n=100 loop until n = 9 print n n = n -1 end loop
i=0 do if(i/2=0) msgbox(i) while(i<=10) wend
It is actually quite easy to write a program in java to do this. The easiest way to do this that I can think of is to use the remainder operator (%) to test whether a number is odd or not. Here is a simple program that will print out all the odd numbers between 1 and 50. public class OddNumbers { public static void main(String[] args) { int i=1; while(i < 50) { if(i%2 != 0) { System.out.println(i); } i++; } } }
Oh, dude, to print those numbers in QBasic, you can use a simple loop. Just loop from 1 to 5 and print the numbers with spaces in between. It's like making a sandwich, but with numbers instead of bread and cheese. So, like, don't stress, just code it up and hit run. Easy peasy, right?
You can use a PL/SQL block to display numbers from 1 to n in Oracle. Here's an example program: DECLARE n NUMBER := 10; -- Change this value to your desired n BEGIN FOR i IN 1..n LOOP DBMS_OUTPUT.PUT_LINE(i); END LOOP; END; / This code declares a variable n, then uses a FOR loop to iterate from 1 to n, printing each number using DBMS_OUTPUT.PUT_LINE. Make sure to enable output in your SQL environment to see the results.
to display 10 numbers in C language we can use the while loop.... #include<stdio.h> #include<conio.h> void main() { int n=0; while(n<=10) { printf("%d",n); //it will print the 10 numbers as output } getch(); }
int i; for (i=10; printf ("%d\n", i); i--);
n=100 loop until n = 9 print n n = n -1 end loop
i=0 do if(i/2=0) msgbox(i) while(i<=10) wend
int i;for (i=10; i
It is actually quite easy to write a program in java to do this. The easiest way to do this that I can think of is to use the remainder operator (%) to test whether a number is odd or not. Here is a simple program that will print out all the odd numbers between 1 and 50. public class OddNumbers { public static void main(String[] args) { int i=1; while(i < 50) { if(i%2 != 0) { System.out.println(i); } i++; } } }
The basic idea is as follows. Assume an array n(), of ten elements.* Set variable "highest" to the first number, n(1). * Set index "i" equal to 2. * Do the following in a loop: * If n(i) is greater than "highest", replace "highest" with n(i). * Increment i by 1. * Compare whether "i" is greater than 10. If it is, leave the loop. * Display variable "highest".
Oh, dude, to print those numbers in QBasic, you can use a simple loop. Just loop from 1 to 5 and print the numbers with spaces in between. It's like making a sandwich, but with numbers instead of bread and cheese. So, like, don't stress, just code it up and hit run. Easy peasy, right?
#include using std::cout;using std::endl;int main(){cout
% 1. Define starting and ending counter values (numerical values = numbers) starting=1; % for example, this for-loop is starting from number "1" ending=10; % for example, this for-loop is ending at number "10" % 2. Define what you want to do with the for-loop % For example, you can display ten times (on the Command Window) % "The quick brown fox jumps over the lazy dog." for id=starting:ending disp('The quick brown fox jumps over the lazy dog.'); end % 3. See: MATLAB Manual
Loops are used when you wish to run the same code multiple times, often slightly differently each time. For example if you wanted to display the numbers 1 to 10 you would most likely use a loop.