Dyskusje Q&A
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 głosów
11 odpowiedzisave as
1 Głos
2 odpowiedziChess tournment
0 głosów
2 odpowiedziPublic, static and void
0 głosów
2 odpowiedziSuggestion
2 głosów
2 odpowiedziwhere's the error ?
-3 głosów
2 odpowiedziCan 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 głosów
8 odpowiedziNeed help
1 Głos
3 odpowiedziclass and object
1 Głos
1 OdpowiedźWhye error???
0 głosów
1 OdpowiedźGENERIC CLASSES i want your help
-3 głosów
1 OdpowiedźWhy is not working
0 głosów
3 odpowiedziwhat's the error in my code?
0 głosów
1 OdpowiedźI am confused on this
0 głosów
1 Odpowiedź#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 głosów
1 Odpowiedźjava learning
0 głosów
1 OdpowiedźWhy not working
-4 głosów
4 odpowiedziPopularne dzisiaj
How to allow one instance of exe
1 Votes
purchase of a subscription
1 Votes
What has happened?
1 Votes
Theater management help me
2 Votes
What should I add/improve ?
1 Votes
Tools for web design?
1 Votes