//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
A finite loop executes a specific number of times based on its condition, while an infinite loop runs indefinitely without cessation. Finite loops have a predetermined endpoint, while infinite loops continue without a defined stopping condition until manually interrupted. Improperly written infinite loops can lead to system crashes or unresponsive programs.
10 CLS 20 FOR n = 1 to 10 30 PRINT n, n^2, n^3 40 NEXT n 50 PRINT: PRINT: PRINT "Touch 'x' to go again, any other key to end." 60 INPUT a$ 70 IF a$ = "X" or a$ = "x" THEN 10 80 END
AnswerDDA uses float numbers and uses operators such as division and multiplication in its calculation. Bresenhams algorithm uses ints and only uses addition and subtraction. Due to the use of only addition subtraction and bit shifting (multiplication and division use more resources and processor power) bresenhams algorithm is faster than DDA in producing the line. Im not sure, though if i remember right, they still produce the same line in the end.One note concerning efficiency: Fixed point DDA algorithms are generally superior to Bresenhams algorithm on modern computers. The reason is that Bresenhams algorithm uses a conditional branch in the loop, and this results in frequent branch mispredictions in the CPU. Fixed point DDA also has fewer instructions in the loop body (one bit shift, one increment and one addition to be exact. In addition to the loop instructions and the actual plotting). As CPU pipelines become deeper, mispredictions penalties will become more severe.Since DDA uses rounding off of the pixel position obtained by multiplication or division, causes an accumulation of error in the proceeding pixels whereas in Bresenhams line algorithm the new pixel is calculated with a small unit change in one direction and checking of nearest pixel with the decision variable satisfying the line equation.BUT this error can be calculated and will not cause problems for typical line drawing applications. Lines longer than what fits on a typical computer screen (a few thousand pixels) will be identical to Bresenham lines when using 32 bit integers. Fixed point DDA also has another advantage: Since it does not require conditional jumps, you can compute several lines in parallel with SIMD (Single Instruction Multiple Data) techniques.
Higher expectations and increased support. Teachers who believed in the students' potential and provided additional resources and encouragement helped them excel academically. This support created a positive feedback loop that motivated the students to work harder and achieve greater success.
There are basically two classical theories of motor learning, Adam's two stage theory and Fitts and Posner's theory. Adam's two stage theory comprise of two stages: elements of motor behavior and how learning proceeds. Fitts and Posner's theory has three stages: element learning, associative stage and autonomous stage.
A = 5do{statement;A = A + 1;} while (A < 10)
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
How do you write a program with do while loop so that the output is 123456 =720
int i=0; while (i++<n) { /*...*/ }
Wr
Exactly what do you mean by 'C program in Java'
Not used
printf ("x")
Yes. The same goes for for-loop and do-while-loop.
write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?
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.