#include<stdio.h>
main()
{
int a,i=1;
printf("Enter max no");
scanf("%d",&a);
do
{
printf("%d",i);
i=i+2;
}while(i<=a);
}
A program can be looped in Python by wrapping the entire program in a for or while loop. If you wish to loop the program a finite amount of times, it can be done like so (x = the amount of times you want it to loop, this can be a number or variable storing a number): for i in range(0,x): [code] If you wish to loop the program infinitely, you can use a simple while loop: while True: [code]
With loops, your program is slower.
#include<stdio.h> int main () { int odd=1; int count=0; while (count++<10) { printf (%d\n", odd); odd+=2; } return 0; }
for loop and while loop need the expression to be true for further execution of the program.
A = 5do{statement;A = A + 1;} while (A < 10)
A program can be looped in Python by wrapping the entire program in a for or while loop. If you wish to loop the program a finite amount of times, it can be done like so (x = the amount of times you want it to loop, this can be a number or variable storing a number): for i in range(0,x): [code] If you wish to loop the program infinitely, you can use a simple while loop: while True: [code]
The runtime complexity of a while loop in a program is typically O(n), where n represents the number of iterations the loop performs.
//program to find the factorial value f any number using while loop #include<stdio.h> void main() { int i,n,fact=1; printf("Enter the number\n"); scanf("%d",&n); i=n; while (i>=1) { fact=fact*i; i--; } printf("The factorial value=%d",fact); } the above is a program for calculating tha factorial value of any number which is entered by the user
How do you write a program with do while loop so that the output is 123456 =720
With loops, your program is slower.
#include<stdio.h> int main () { int odd=1; int count=0; while (count++<10) { printf (%d\n", odd); odd+=2; } return 0; }
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.
how do we use loops in c plus plus programing and what are basic differences between do,for and while loop
for loop and while loop need the expression to be true for further execution of the program.
#include<stdio.h> #include<conio.h> void main() { int a=n; do {for("a<=n",%d); while {for ("a=n",number); getch(); }
Not used
An infinite loop might look something like: while 1==1: print("Infinite loop") as 1 is ALWAYS equal to 1.