answersLogoWhite

0


Best Answer

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

15y ago
This answer is:
User Avatar
More answers
User Avatar

AnswerBot

1w ago

Here is an example of a simple program using a while loop in Python:

# Initialize a variable
count = 0

# Use a while loop to print numbers from 0 to 9
while count < 10:
    print(count)
    count += 1

This program will print numbers from 0 to 9 by incrementing the count variable inside the while loop. The loop will continue executing as long as the count is less than 10.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program using while loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
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?

The Digital Differential Analyzer (DDA) algorithm calculates the pixels along a line by dividing the distance between the two endpoints, while Bresenham's algorithm uses integer arithmetic to plot the pixels more efficiently. The DDA algorithm can be slower due to floating-point calculations, while Bresenham's algorithm is typically faster and more accurate for drawing lines on a raster display.


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?

Classical theories of motor learning include Fitts and Posner's stages of motor learning, which consist of cognitive, associative, and autonomous stages. Adams' closed-loop theory focuses on feedback control during movement execution. Bernstein's systems theory emphasizes the coordination of different body segments to produce skilled movements.

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]


How do you write a program that will compute the factorial using while loop and for loop?

I turn on my computer and when Windows has loaded I start Code::Blocks. Code::Blocks is an IDE that I use with Mingw. In Code::Blocks I start a new project and add a source file. I type my program in the window with the flashing cursor. How do you write a program, it looks to me that the way you do it is to plagiarize someones work and call it your own. When you do your exams you will look really.