Q&A Discussões
i want to print sum of all integers from 1to 100 like for example :
1
3
6
10
15......
i tried it i know my code is wrong please help me class Program {
public static void main(String[] args) {
for(int x = 1; x <101; x++) {
int sum = int x;
System.out.println("1");
System.out.println("sum");
}
}
}
3 Votos
11 Respostassave as
1 Voto
2 RespostasChess tournment
0 Voto
2 RespostasSuggestion
2 Votos
2 Respostaswhere's the error ?
-3 Votos
2 RespostasCan someone explain this code to me....
class ReverseNumberDemo
{ public static void main(String args[]) {
int num=123456789;
int reversenum =0;
while( num != 0 ) {
reversenum = reversenum * 10;
reversenum = reversenum + num%10;
num = num/10; }
System.out.println("Reverse of specified number is: "+reversenum);
}
}
the thing I don't get is the reversenum part......isn't reversenum=0 so wouldn't reversenum*10=0
0 Voto
8 RespostasNeed help
1 Voto
3 Respostasclass and object
1 Voto
1 RespostaWhye error???
0 Voto
1 RespostaWhy is not working
0 Voto
3 RespostasI am confused on this
0 Voto
1 Resposta#include <iostream>
using namespace std;
class A{
public:
void f1();
};
class B : public A{
public:
virtual void f1();
}
int main()
{
A * obj = new B;
obj.f1();
}
Ques: can we write virtual before an overridden function from the base class?? if yes which f1() should it call base class f1() or derived class f1()???
0 Voto
1 Respostajava learning
0 Voto
1 RespostaWhy not working
-4 Votos
4 RespostasQuente hoje
Help please?
3 Votes
Ejercicio Pytho
0 Votes
Online voting system
2 Votes
What is that z for
0 Votes
Suggestions needed
4 Votes
SQL practice
2 Votes
Game development
0 Votes