Ask a Question | Answer a Question! |
Submitting your question...
ResFinder - Thousands of Practice Papers
code for happy no. is below
import java.io.*;
public class happyormagical
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a no.");
int n=Integer.parseInt(br.readLine());
int sum=n;
while(sum>9)
{
n=sum;
sum=0;
while(n>0)
{
int rem=n%10;
sum=sum+rem*rem;
n=n/10;
}
}
if(sum==1)
System.out.println("Happy no.");
else
System.out.println("Not a Happy no.");
}
} |
|
asked by Bhavesh Choudhari (bhavesh988) 8 years ago |
1 |
Guys, when they say use comment lines should we write comments wherever possible while writing the program or...is it something else?
(also do you know what are the most predicted prog. questions? :/ )
Thanks! |
|
asked by Tabassum (thesilverlining) 8 years ago |
1 |
Instance variables are class variables right? If not whats the difference? |
|
asked by Abhishek Agrawal (agrek) 8 years ago |
1 |
+ 2 more questions by agrek
Syntax of final keyword with example? |
|
asked by Abhishek Agrawal (agrek) 8 years ago |
2 |
What does an exclamation mark mean next to numbers in series programs? |
|
asked by Abhishek Agrawal (agrek) 8 years ago |
1 |
Is it compulsory to write comments ? |
|
asked by Prateek Rawat (prateek25) 8 years ago |
2 | + 3 more questions by prateek25
Write a Program to Compare two Strings using Scanner Class. |
|
asked by Prateek Rawat (prateek25) 8 years ago |
1 |
Write a Program to find the Roots of Quadratic Equation. |
|
asked by Prateek Rawat (prateek25) 8 years ago |
0 |
Write a Program to find the Substring of Strings.For example substrings of “fun” are :- “f”, “fu”, “fun”, “u”, “un” and “n” |
|
asked by Prateek Rawat (prateek25) 8 years ago |
1 |
Guys one doubt : can the actual and the formal variables be the same ??
Like boolean b(int a,int b)
And then in main ()
on.b(a,b)
Plz I'm having this confusion for a month;!! |
|
asked by Abhishek Shyam (abhibenne) 8 years ago |
2 |
Guys can u sort this array for me?
String array = {"q" , "s", "a", "y", "b"};
Thanks |
|
asked by Chelsea Dcosta (che777) 8 years ago |
4 |
can someone tell me which paper to go through like which one is important except the boards(all) and specimen paper2015 |
|
asked by Pj Pj (pj2000) 8 years ago |
1 | + 2 more questions by pj2000
example of library classes plz |
|
asked by Pj Pj (pj2000) 8 years ago |
1 |
can someone plz tell me a full definition of a package...is it just a group of related classes? |
|
asked by Pj Pj (pj2000) 8 years ago |
1 |
GUYS GREAT NEWS ...........
.
.
.
.
.
.
.
.
Only 19 hours to freedom . |
|
asked by The Dark Lord (shashank44thool) 8 years ago |
3 |
Name the two real literals of java. Mention the size of each, in bytes. |
|
asked by Lord Roshan the Great (lordroshan) 8 years ago |
2 |
Is compulsory to write comments ? |
|
asked by Vedant Sardal (vedantsardal) 8 years ago |
2 |
| | |