answersLogoWhite

0

//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

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Educational Theory

Differences between finite and infinite loop?

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.


Write a qbasic program to print the squares and cubes of first 10 natural numbers?

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


Differences between digital differential analyzer and bresenham algorithm?

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.


In the Rosenthal study of academic bloomers the children who improved their performance over the year did so because of their teachers'?

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.


What are classical theories of motor learning?

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.

Related Questions

Write a program that will graph using for loop?

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 nos vertically?

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 equals 720?

How do you write a program with do while loop so that the output is 123456 =720


How do you write a c program to print n no's required using while loop?

int i=0; while (i++&lt;n) { /*...*/ }


How do you write a c program to design calculator using loop?

Wr


Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


C program algorithm for simple interest using while loop?

Not used


How do you write a C plus plus program that displays a pyramid of Xes on the screen using a for loop?

printf ("x")


Can you write switch statement with in while loop?

Yes. The same goes for for-loop and do-while-loop.


Write a program that input a positive integer and prints a triangle using for 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?


How do you loop a program in python 3?

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]


What is the runtime complexity of a while loop in a program?

The runtime complexity of a while loop in a program is typically O(n), where n represents the number of iterations the loop performs.