write a program that will ask the user to enter a number n and
display the product of all numbers from 1 to n.



write a program that will ask the user to enter a number n and display the product of all numbers ..

Answer / anubhavtiwari87

#include<stdio.h>
#include<conio.h>
void main()
{
int n,result;
result=1;
clrscr();
printf("enter the number");
scanf("%d",&n);
for(int i=n;i>=1;i--)
{
result=result*i;
}
printf("the desired result = %d",result);
}

Is This Answer Correct ?    8 Yes 10 No

Post New Answer

More J2SE Code Interview Questions

Why we r using String args[] in main() even though v r not passing any arguments in command line?

2 Answers  


how to print a message to console without using main() function?(do not use even static blocks also.)

14 Answers   Google, Zoho,


In java, why do we set thread priority, when we know that there is no guarantee by which a thread should be execute?

0 Answers   Google, Microsoft,


Why the program getting error if we don't use String args[] in main(), even in the case of not getting any arguments from command line?

1 Answers  


How can we get the details for printing the employee details at run time using JDBC connectivity? can u provide the coding for that? Its urgent?

2 Answers  


write a program in java to solve a system of n-variabled simultaneous equations using the guassian elimination method. let the maximum possible value of n be 100. run the program using hypothetical values for a set of 10- variables simultaneous equations. print out the program, the input equation and the results generated by the program.

0 Answers   TCS,


Program to print map of India in java.

2 Answers  


Write a java program to display multiplication table in a Frame.

1 Answers  


write a c program which takes 20 numbers in an array as input from user and rearrange them in two different array defining even or odd

0 Answers  


A game that has five levels of play has the score for each level stored in an array. You are to write a program that goes through that array and finds: a) the minimum score, and the level at which it occurred b) the maximum score, and the level at which it occurred c)the average score for all five levels The score data you must use for this program are as follows: Game Level Score 1 450 2 316 3 148 Stack implementations is mandatory.

0 Answers  


For printing a message we use System.out.println in normal programs. We use String msg="text....."; Can't we use String msg=" " in normal programs and System.out.println("........") in applets. Please answer this question?

0 Answers  


Can we run Applet in Web browser with security policy files

0 Answers  


Categories