answersLogoWhite

0


Best Answer

#include <iostream> void main() { using namespace std; int num, rem, sum=0; //Declaring variables cout<<"Enter a number :"<<endl; cin>>num; //Loop to calculate the sum of the digits of the given number. while(num!=0) { rem=num%10; num=num/10; sum=sum+rem; } cout<<"Sum of the digits is "<<sum<<endl; cin.get(); }

User Avatar

Wiki User

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

Wiki User

11y ago

class prime

{

public static void main(String p[])

{

int i,j,s=0,d=0;

for(i=1;i<100;i++)

{

s=0;

for(j=1;j<=i;j++)

{

if(i%j==0)

s=s+1;

}

if(s==2)

{

System.out.println(i);

d=d+1;

}

}

System.out.println("the no. of prime no. are = "+d);

}

}

Read more: http://wiki.answers.com/Simple_java_program_to_find_prime_numbers#ixzz269bk91Ms

This answer is:
User Avatar

User Avatar

Wiki User

11y ago
class prime

{

public static void main(String p[])

{

int i,j,s=0,d=0;


for(i=1;i<100;i++)

{

s=0;

for(j=1;j<=i;j++)

{

if(i%j==0)

s=s+1;

}

if(s==2)

{

System.out.println(i);

d=d+1;

}

}

System.out.println("the no. of prime no. are = "+d);

}

}


This answer is:
User Avatar

User Avatar

Wiki User

12y ago

There is nothing needed as input.

But if "input" as the argument passing to a routine, it depends on the routine.

It can be a function to determine any given integer (here's the input) is a prime or not, or it can be a function to return all the prime numbers within a range (1 to 100 in this case).

  • the smallest Prime = 2, the only even number as a Prime number!
  • any other prime number other than 2 is a POSITIVE ODD INTEGER
This answer is:
User Avatar

User Avatar

Wiki User

13y ago

linearly

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What input you will give to write a basic program to find prime numbers between 1 to 100 using if and else?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

The distance between two cities in km is input through the keyboard write a program to convert and print this distance in meters feet inches and centimeters?

mesh's basic salary is input through the keyboard. his dearness allowance is 40% of basic salarying , and house rent allowance is 20% of basic salaried. write a program to calculate his gross salary


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


How do you create a program that can input 100 names using flowchart?

create a program that can input 100 names


What you meant by yacc tool in compiler design?

Yacc provides a general tool for imposing structure on the input to a computer program. The Yacc user prepares a specification of the input process; this includes rules describing the input structure, code to be invoked when these rules are recognized, and a low-level routine to do the basic input. Yacc then generates a function to control the input process. This function, called a parser, calls the user-supplied low-level input routine (the lexical analyzer) to pick up the basic items (called tokens) from the input stream.


What is meant by input stream?

An input stream is a character sequence device or buffer from which input can be gathered. The standard input stream is usually a keyboard, data file or the output stream from another program. The user of the program can normally decide where standard input may be redirected from when launching the program, typically defaulting to the keyboard.

Related questions

How do you prepare a program in basic to display the word and the number of letters in it when is given as input?

10 cls 20 input"enter word";word$ 30 print word$ 40 print len(word$) 50 end this program is for GW BASIC for other BASIC's the line numbers are optional.


What is the program that manages the data between the operation system and all input and output devices attached to the system?

basic input output system (BIOS)


How do you write BASIC program to accept variables?

dim a input a


The distance between two cities in km is input through the keyboard write a program to convert and print this distance in meters feet inches and centimeters?

mesh's basic salary is input through the keyboard. his dearness allowance is 40% of basic salarying , and house rent allowance is 20% of basic salaried. write a program to calculate his gross salary


What is the bios set up program called?

there is no bios setup program but BIOS stands for basic input output system


What program is responsible for loading the operating system into RAM?

Basic Input/Output System (BIOS)


Sum three real numbers using for loop in c program?

take input n chodo


How do you input an operator between two numbers in java?

You type it in with your keyboard.


What is legal input?

In a computer program, a legal input is something that can be put into a program and it will work. An illegal input may crash the program.


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


What is the program to find sum of n natural numbers in c plus plus?

Initialise an unsigned integer to zero. As each number is input, increment the running total accordingly. When all numbers are input, display the total.


What is a program to input any two numbers and print their sum and product by leaving two lines in between?

Since you didn't specify, I will give you the answer for a TI 83 Plus Silver Addition :Input A :Input B :ClrHome &lt;--found in the prgm menu with input :Output(1,1,A+B) &lt;--Output also found in same menu as ClrHome :Output(4,1,A*B)