d2jsp
Log InRegister
d2jsp Forums > Off-Topic > International > Svenska > C++ Noob Behöver Hjälp
Prev12
Add Reply New Topic New Poll
Member
Posts: 4,980
Joined: Jan 16 2010
Gold: 0.00
Warn: 20%
Jan 12 2012 01:01pm
Quote (fideuu @ 12 Jan 2012 19:54)
/e

tack grandebedte, fan att man alltid ska missa något. Letade i ca en kvart utan resultat.

/e2 är inte känd för att vara bra på att leta dock ;P


Np.

Du får nok hurtigere hjælp herinde:
http://forums.d2jsp.org/forum.php?f=122
Member
Posts: 20,173
Joined: Sep 28 2009
Gold: 3,352.14
Jan 12 2012 01:55pm
Quote (Fil @ Jan 12 2012 08:55pm)
nej, här har han glömt skriva ==

det har grandebedte redan påtalat dock



konstigt, du får väl ändå felmeddelande som till och med berättar på vilken rad? Så du satt alltså i en kvart och upptäckte inte det där? :P


ja haha xD :(


Quote (Grandebedte @ Jan 12 2012 09:01pm)
Np.

Du får nok hurtigere hjælp herinde:
http://forums.d2jsp.org/forum.php?f=122


just that i need some help in swedish for this one.

Hittar ingen bra förklaring på loopar,

#include<iostream>

using std::cout;

int main()
{
int tal;
tal = 1;

while (tal <= 100)
{
cout << tal << "\n";
tal+=1;
}

detta är hur man ska göra enligt guiden jag läser m.m.
det finns en förklaring men förstår inte riktigt, om någon snäll pajk skullle kunna göra det lite klarare för mig vore det uppskattat.



This post was edited by fideuu on Jan 12 2012 01:58pm
Member
Posts: 4,980
Joined: Jan 16 2010
Gold: 0.00
Warn: 20%
Jan 12 2012 02:13pm
Quote (fideuu @ 12 Jan 2012 20:55)
ja haha xD :(




just that i need some help in swedish for this one.

Hittar ingen bra förklaring på loopar,

#include<iostream>

using std::cout;

int main()
{
  int tal;
  tal = 1;

  while (tal <= 100)
  {
    cout << tal << "\n";
    tal+=1;
  }

detta är hur man ska göra enligt guiden jag läser m.m.
det finns en förklaring men förstår inte riktigt, om någon snäll pajk skullle kunna göra det lite klarare för mig vore det uppskattat.

First, you declare an integer named tal, and set the value of it = 1.
Then, you run through the code
Code

    cout << tal << "\n";
    tal+=1;

as long as
Code
while (tal <= 100)
is true.

Example: first time you get to the while loop, tal == 1, meaning that (tal <= 100) == true, further meaning that you execute the code inside the while. The inner code prints tal (which is == 1 now), and sets tal = tal+1;
Now the code checks whether (tal <= 100) is still == true - if it is true, it will once again execute the code inside the while loop, and continue to do so, until tal > 100.

If you're having problems seeing what your code does, I can really recommend you sitting down and going through it on a piece of paper with a pencil. You can spot a lot of mistakes and get a general understanding that way. :)
Member
Posts: 36,992
Joined: Jan 6 2007
Gold: 7,821.00
Jan 12 2012 02:18pm
Quote (Grandebedte @ 12 Jan 2012 21:13)
First, you declare an integer named tal, and set the value of it = 1.
Then, you run through the code
Code
cout << tal << "\n";
    tal+=1;

as long as 
Code
while (tal <= 100)
is true.

Example: first time you get to the while loop, tal == 1, meaning that (tal <= 100) == true, further meaning that you execute the code inside the while. The inner code prints tal (which is == 1 now), and sets tal = tal+1;
Now the code checks whether (tal <= 100) is still == true - if it is true, it will once again execute the code inside the while loop, and continue to do so, until tal > 100.

If you're having problems seeing what your code does, I can really recommend you sitting down and going through it on a piece of paper with a pencil. You can spot a lot of mistakes and get a general understanding that way. :)


det här är sant! att sätta sig och gå igenom med papper vad som händer gör duktigt stor skillnad när man sitter och programmerar! Åtminstone för förståelsen!
Member
Posts: 984
Joined: Jan 17 2009
Gold: 0.01
Jan 12 2012 03:45pm
hejsan jag kände för att börja lära mig lite c++ började precis för cirka 1 timma sedan och jag vet inte riktigt hur jag ska börja, hittade en guide och jag laddade ner visual ++ men sen när jag skriver

// hejsan

#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!";
return 0;
}

så får jag error, det kan vara att jag inte öppnat rätt när jag gjorde nytt, please help
Member
Posts: 4,888
Joined: Apr 4 2007
Gold: 6,054.15
Jan 13 2012 07:56am
Quote (daggmaskine @ 12 Jan 2012 23:45)
hejsan jag kände för att börja lära mig lite c++ började precis för cirka 1 timma sedan och jag vet inte riktigt hur jag ska börja, hittade en guide och jag laddade ner visual ++ men sen när jag skriver

// hejsan

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

så får jag error, det kan vara att jag inte öppnat rätt när jag gjorde nytt, please help


Kan det vata så att du inte hinner läsa vad som står? consollen bara stänger ner?

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{

cout << "Hello world!" <<endl;

system("PAUSE");
return EXIT_SUCCESS;
}


Om du inte har "Pause" före return, så kan det hända att den bara blinkar till liksom. Skicka PM om det fortsätter att strula. Testa kopiera min kod om det nu inte fungerar.

ENDL - EndLine är också en bra grej att veta. Den gör så att texten efteråt hoppar ner, som ett "enter" slag på tangentbordet. Har du inte ENDL så fortsätter allting på en rad.

This post was edited by Vigge on Jan 13 2012 08:06am
Member
Posts: 20,173
Joined: Sep 28 2009
Gold: 3,352.14
Jan 13 2012 09:15am
Quote (Grandebedte @ Jan 12 2012 10:13pm)
First, you declare an integer named tal, and set the value of it = 1.
Then, you run through the code
Code
cout << tal << "\n";
    tal+=1;

as long as 
Code
while (tal <= 100)
is true.

Example: first time you get to the while loop, tal == 1, meaning that (tal <= 100) == true, further meaning that you execute the code inside the while. The inner code prints tal (which is == 1 now), and sets tal = tal+1;
Now the code checks whether (tal <= 100) is still == true - if it is true, it will once again execute the code inside the while loop, and continue to do so, until tal > 100.

If you're having problems seeing what your code does, I can really recommend you sitting down and going through it on a piece of paper with a pencil. You can spot a lot of mistakes and get a general understanding that way. :)


thanks. with this explanation and just using ur tip it made it all alot more clearly.

tack alla, kommer återkomma till denna tråden när jag får mer problem så slipper vi f
Go Back To Svenska Topic List
Prev12
Add Reply New Topic New Poll