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 odpowiedziwhat's wrong in this condition
prompt ("")
if (prompt ("1")) {
document.write("<h1>HTML Tutorial</h1>");
} else if (prompt ("2")) {
document.write("<h1>CSS Tutorial</h1>");
} else {
document.write("<h1>JavaScript Tutorial</h1>");
}
I want when type 1 in output HTML tutorial shows, type 2 css tutorial shows else javascript tutorial
0 głosów
13 odpowiedziHi, I need assistance aka HELP!
I've done this calculation in various ways some of printed nothing but zeros non stop.
Using while loop calculate all numbers 1 to 1000 add numbers to sum = sum + i
int sum = 0;
// use a while loop to calculate the sum of 1 to 1000
While(int sum = 0; sum >= 1000; sum = sum + I){
System.out.println(sum);
}
0 głosów
4 odpowiedziIn the code below the output is 2. This code is used in a challenge and I get an error when I select the answer 2. It accepts as correct the answer 1 which I believe is wrong. If you agree please thumbs up.
If you find any other errors please post them here!
#include <iostream>
using namespace std;
int main()
{
for(int i=1; i>=1; i++) {
if(i<1 || i>1){
cout << i;
break;
}
}
return 0;
}
8 głosów
8 odpowiedzi
what have i to do, if i want that the program always writes for example :
0+1
1+2
3+3
6+4
10+5
15+6
...
because now it just writes
1
3
6
10
15
...
and maybe if it works, can i make then
0+1=1
1+2=3
3+3=6
6+4=10
#include <iostream>
using namespace std;
int main(){
int i;
int sum = 0;
for (i = 1; i <= 100; i++){
sum = sum+i;
cout<<sum<<endl;
}
cout<<sum;
return 0;
}
1 Głos
5 odpowiedzihow do I get line breaks?
name = input("What is your name?:")
print("Hiya, " + name)
age = int(input("Tell me your age:"))
year = str((2016 - age) + 100)
num = int(input("Enter a number between 1 and 50:"))
line = str((name + " will be 100 in the year " + year) * num)
print(\n line)
2 głosów
3 odpowiedziso far in section 1 question 2 area all of the videos have been ads that if you skip the add it just brings up the questions you need to answer. also if you play the add all the way thru you get the same exact thing. luckily I'm using this as a refresher course but I would think if I didn't know anything about c++ then I could be pretty lost missing videos.
0 głosów
2 odpowiedzican someone tell me how to make it impossible for a user to type a 'userchoice1[x]' value that does not range from 1 - 10.
If you also know a way I can make the user input another value for the 'userchoice1[x]' variable if it is less than 1, I'll appreciate you share the knowledge with me.
please see the short code below
1 Głos
2 odpowiedziPopularne dzisiaj
Help please?
4 Votes
Ejercicio Pytho
0 Votes
What is that z for
0 Votes
Suggestions needed
4 Votes
Game development
0 Votes
Ruby programming?
3 Votes