writing programs

writing programs

1.write a program to display odd numbers from 1-50.


2.And Write a program to find the facorial of a number
View Answers

May 10, 2010 at 10:52 AM

Hi Friend,

1)
class OddNumbers{
public static void main (String args[]){
String oddNo = "";
for (int i = 1; i <=50; i++){
if (i % 2 != 0) {
oddNo += i + " ";
}
}
System.out.println("Odd Numbers between 1 to 50 are: "+oddNo);
}
}

2)
import java.util.*;
class factorial{
public static void main(String []args){
Scanner input=new Scanner(System.in);
System.out.print("Enter Number:");
int num=input.nextInt();
long fac=num;
for(int i=num;i>1;i--)
{
fac=fac*(i-1);
}
System.out.println(fac);
}
}

Thanks









Related Tutorials/Questions & Answers:
writing programs - Java Beginners
writing programs  1.write a program to display odd numbers from 1-50. 2.And Write a program to find the facorial of a number  Hi Friend, 1) class OddNumbers{ public static void main (String args
writing java programs - Java Beginners
writing java programs  How do i write a code to display even numbers from 1 to 50  Hi Friend, Try the following code: class EvenNumbers{ public static void main (String args[]){ String evenNo
Advertisements
programs
programs  give some programs on control statementds
Programs in java
Programs in java  Hi, What are the best programs in java for a beginner? Thanks
php programs
php programs  10 programs on varibles
java programs
java programs  Why word "static" is used in java programs
writing characters
writing characters  how to write a group of characters to a string ... i mean for writing single character using charAt in java
Java Programs
Java Programs  Hi, What is Java Programs? How to develop application for business in Java technology? Is there any tool to help Java programmer in development of Java Programs? Thanks
php programs
php programs  I need 15 programs on arithmetic operators with comments. Please help me
java programs
java programs  Explain types of Java programs. Also explain how to compile and run them.   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
programs in java
programs in java  . I need an application for managing an educational institute. That application should provide the details of Students Courses Faculty Fee details etc.., pl z guide me how to write these programe
java programs
java programs  i need help in understanding the whole concept of the 13 java programs that i hav...here r de programs.. int i,j,m,n; m=Integer.parseInt(args [0]); n=Integer.parseInt(args [1]); System.out.print
programs
programs
c++ programs
c++ programs  i want the syntax for the following programs according to c++ pattern. 1.sum of multiples of an integer upto 10 2.2/4+4/6+6/8+8/10+.....n/n+2 3.1!/1+2!/2+3!/3+4!/4+...n!/n i just want the main logic as i m nt
Ghost Writing
Ghost Writing Ghost Writing is the kind of writing when someone... of writing it. So ghostwriter is a person who works behind the scene on a writing project in return of certain amount. The write-ups of the writer
Blog Writing
Blog Writing A blog, the short form of web log is an online user... on that. But the professionals are a better choice for writing the blog for commercial or promotional purpose. We provides the services of writing blogs for the commercial
java programs
java programs  A union B, transpose of matric, denomination of a given number i need java programs for this category?   Hi Friend, Transpose of matrix: import java.util.*; public class Transpose { public
Writing Actions
Writing Actions The Action is responsible for controlling of data flow within an application. You can make any java class as action. But struts have some built in interface and class for making action easily. To make an Action class
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
JSF Sample Programs
JSF Sample Programs  I need a JSF sample programs
writing plugin - WebSevices
writing plugin  can anyone help me in writing plugin for internet explorer browser using c++ in .net environment
writing HTML entirely by hand
writing HTML entirely by hand  How comfortable are you with writing HTML entirely by hand
Web Writing
Web Writing       The art of writing for the web is far removed from writing for the print world.... Following is the prime aspect you need to keep in mind while writing for the web
SEO Writing
SEM and SEO Article Writing SEM and SEO article helps your business to grow... the intended traffic through SEM and SEO article writing in addition to other tools... is the demand of SEM and SEO article writing services. A good command over
writing webservices in php
writing webservices in php  How to write a simple web service in PHP
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
Explain types of java programs
Explain types of java programs  Explain types of java programs   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
RUNNING EJB PROGRAMS
RUNNING EJB PROGRAMS  how to run ejb programs using weblogic in windowsxp
how to compile programs??????????
how to compile programs??????????  "javac" is not recognised as a file name. why??????????   Have you set your path name and class name correctly? Anyways have a look at the following link: Install Java
advantage of stored programs
advantage of stored programs  Which of the following is an advantage of stored programs? a) Reliability b)Reduction in operation costs c) The computers becoming general purpose D) All of the above E) None of these  
user define exception programs
user define exception programs  user define exception programs   Please visit the following links: http://www.roseindia.net/java/java-exception/user-defined-exception.shtml http://www.roseindia.net/java/exceptions
j2ee example programs
j2ee example programs   can any one tell me how to develop and execute ---------- j2ee entity beans (cmp,bmp) example,message driven bean example ,webservices example in weblogic server with (netbeans or eclipse
Java programs for beginners
RoseIndia provides a long list of Java programs for beginners that too for free. This tutorials and programs are available online and can be used... prepared these java programs describing every logic and method behind
data science programs ranking
data science programs ranking  Hi, I am beginner in Data Science... science programs ranking Try to provide me good examples or tutorials links so that I can learn the topic "data science programs ranking". Also tell me
phd programs in artificial intelligence
phd programs in artificial intelligence  Hi, I am beginner in Data...: phd programs in artificial intelligence Try to provide me good examples or tutorials links so that I can learn the topic "phd programs in artificial
masters programs in artificial intelligence
masters programs in artificial intelligence  Hi, I am beginner... to learn: masters programs in artificial intelligence Try to provide me good examples or tutorials links so that I can learn the topic "masters programs
masters programs for data science
masters programs for data science  Hi, I am beginner in Data Science...: masters programs for data science Try to provide me good examples or tutorials links so that I can learn the topic "masters programs for data science"
machine learning programs in python
machine learning programs in python  Hi, I am beginner in Data...: machine learning programs in python Try to provide me good examples or tutorials links so that I can learn the topic "machine learning programs
question "writing prog"
question "writing prog"  Hello I want helping for this question, please Write a program that reads some friendsā?? names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
15 Php programs on logical operators
15 Php programs on logical operators  I need 15 example programs for logical operators. Please help me out
Java programs - Java Beginners
Java programs  Hello Please write the following programs for me using GUI.Thanks You. 1. Write a java program that reads the first name, last name, hours worked and hourly rate for an employee. Then print the name

Ads