The Official Programming Thread

Shary Bhallu TC

Bhallu is dead, legacy remains
Jun 2, 2009
16,369
692
129
30
Karachi.
This same thing happens in games as well! For example if I am unable to beat a difficult ass Dark Souls 2 boss for hours, then sleep for a few hours, I see that I am able to beat that boss pretty easily. I think our brain does far more than just sleep when we're sleeping. :D
 

MegamanEXE

Well-known member
Dec 7, 2007
1,958
1
43
28
Islamabad
Poori raat beth k banaya, nahi bana.
Subah uth ker 5 minute socha, foran ban gya XD.

Wtf is this sorcery?
Get used to it. This will happen more times than you'll like to admit.

So, if you're stuck for over an hour or 2 using the PC. Leave it, do other stuff, the solution will come as an epiphany! Trust me, happened to me a hundred times. Quoting someone on Quora:
"Programming" is thinking, not typing. Most of programming is spent sleeping, walking around, staring out the window, or doing anything else that helps you relax and think."
 

Shary Bhallu TC

Bhallu is dead, legacy remains
Jun 2, 2009
16,369
692
129
30
Karachi.
Yes my bro said the same thing. One time he was stuck on a problem at his job for 2 days, working 12 hours a day to no avail. He couldn't get his code to work. Then he took a day off from work because he was very tired. After sleeping for almost half of the day, he stumbled upon the solution as soon as he woke up. Called his boss, went to work despite his day off, and his code worked.

Our brains do indeed work while we sleep. Sometimes I've noticed that sleeping for 4-5 hours after studying will help you retain the information you digested just prior to sleeping. I used this technique in the previous hellish semester. It helped me a lot :D!
 

EternalBlizzard

Lazy guy :s
Moderator
Oct 29, 2011
2,732
1,195
129
Attractor Field Beta
Human brain keeps on finding a solution to the problem even while asleep :D That's pretty much a fact now
It keeps on finding a pattern through your problems or so as they say :s A scary thing it is right :D
 
Last edited:

puppet

Well-known member
Sep 30, 2013
2,169
0
42
^^ thats why before coding anything i just make up my mind before designing algo :p
 

Priori

New member
Sep 22, 2014
1
0
1
Hello, I'm looking to learn a new programming language. I have some experience with Android Application Development.

My target is to learn Unity 3D. Can anyone point me to a decent learning resource for beginners or give me any tips etc?
 

puppet

Well-known member
Sep 30, 2013
2,169
0
42
Hello, I'm looking to learn a new programming language. I have some experience with Android Application Development.

My target is to learn Unity 3D. Can anyone point me to a decent learning resource for beginners or give me any tips etc?
c#...... !
 

Benighted

Night is the new day
May 28, 2009
2,476
2
44
31
Tartarus
I've never had those moments of epiphany. I've only ever been able to break down challenging problems by persistent mental effort. And I've only ever done pretty basic programming.
 

Hassan

lethargic procrastinator
Jun 20, 2009
6,273
0
41
3 miles from the nearest bus stop
Can anyone solve this question for me?
Spoiler: show
Create a class called shape using a Header containing only class member functions prototypes (not Definition’s). Store your program in 3 separate files named as Class_Name .h Class definition only function prototypes Class_Name .cpp Class member functions definitions File_Name.cpp Main program for operation
Create a class called shape using a Header containing only class member
functions prototypes (not Definition’s). Store your program in 3 separate files
named as
Class_Name .h  Class definition only function prototypes
Class_Name .cpp  Class member functions definitions
File_Name.cpp  Main program for operation

Your Output should appear as:
Enter your choice (T) for Triangle and (R) for Rectangle and (E) to Exit
T
Enter Value for x 6
Enter Value for y 7
Triangle
Values entered are 6 and 7
Area is 21
Enter your choice (T) for Triangle and (R) for Rectangle and (E) to Exit
R
Enter Value for x 7
Enter Value for y 6
Rectangle
Values entered are 7 and 6
Area is 42
Enter your choice (T) for Triangle and (R) for Rectangle and (E) to Exit
E
Exiting



My poor try with loads of errors
Code:
#include<iostream>
#include<string>
usingnamespacestd;
 
class shape 
{
private:
       inta,b;
public:
       shape()
       {
       a = b = 0;
       }
      
       voidsetvalues()
       {
       cout<<"Enter the values for breath and height:"<<endl;
       cin>> a; cin>> b;
    }
 
       floatarea_r()
       {
       float arear = (a*b);
       return arear;
       }
 
       floatarea_t()
       {
       floatareat = (a*b) / 2;
       returnareat;
       }
 
       voidgetvalues(int x, int y)
       {
       x=a;
       y=b;
       }
 
};
 
voiddisp(int, int, float);
 
int main()
{
       shapevar;
       intm,n;
       stringt,r,e,c;
 
       cout<<"Enter your choice (T) for Triangle and (R) for Rectangle and (E) to Exit:"<<endl;
       getline (cin,c);
      
       do
       {
             
              if (c==t)
              { var.setvalues(); var.area_t(); var.getvalues(m,n); disp(m,n, var.area_t());}
      
 
       elseif (c==r)
              {var.setvalues(); var.area_r(); var.getvalues(m,n); disp(m,n, var.area_r()); }
      
 
       } while (c!=e);
 
       system("PAUSE");
 
return 0;
}
 
voiddisp(inta,int b, float c)
{
       cout<<"The values entered are:"<<endl;
cout<< a << b;
       cout<<"The area is:"<<endl;
       cout<< c;
}
Creating a header file and defining its function in another file is easy. I need help regarding the logic which is to be made.
 

MegamanEXE

Well-known member
Dec 7, 2007
1,958
1
43
28
Islamabad
Can anyone solve this question for me?
Spoiler: show
Create a class called shape using a Header containing only class member functions prototypes (not Definition’s). Store your program in 3 separate files named as Class_Name .h Class definition only function prototypes Class_Name .cpp Class member functions definitions File_Name.cpp Main program for operation
Create a class called shape using a Header containing only class member
functions prototypes (not Definition’s). Store your program in 3 separate files
named as
Class_Name .h  Class definition only function prototypes
Class_Name .cpp  Class member functions definitions
File_Name.cpp  Main program for operation

Your Output should appear as:
Enter your choice (T) for Triangle and (R) for Rectangle and (E) to Exit
T
Enter Value for x 6
Enter Value for y 7
Triangle
Values entered are 6 and 7
Area is 21
Enter your choice (T) for Triangle and (R) for Rectangle and (E) to Exit
R
Enter Value for x 7
Enter Value for y 6
Rectangle
Values entered are 7 and 6
Area is 42
Enter your choice (T) for Triangle and (R) for Rectangle and (E) to Exit
E
Exiting



My poor try with loads of errors
Code:
#include<iostream>
#include<string>
usingnamespacestd;
 
class shape 
{
private:
       inta,b;
public:
       shape()
       {
       a = b = 0;
       }
      
       voidsetvalues()
       {
       cout<<"Enter the values for breath and height:"<<endl;
       cin>> a; cin>> b;
    }
 
       floatarea_r()
       {
       float arear = (a*b);
       return arear;
       }
 
       floatarea_t()
       {
       floatareat = (a*b) / 2;
       returnareat;
       }
 
       voidgetvalues(int x, int y)
       {
       x=a;
       y=b;
       }
 
};
 
voiddisp(int, int, float);
 
int main()
{
       shapevar;
       intm,n;
       stringt,r,e,c;
 
       cout<<"Enter your choice (T) for Triangle and (R) for Rectangle and (E) to Exit:"<<endl;
       getline (cin,c);
      
       do
       {
             
              if (c==t)
              { var.setvalues(); var.area_t(); var.getvalues(m,n); disp(m,n, var.area_t());}
      
 
       elseif (c==r)
              {var.setvalues(); var.area_r(); var.getvalues(m,n); disp(m,n, var.area_r()); }
      
 
       } while (c!=e);
 
       system("PAUSE");
 
return 0;
}
 
voiddisp(inta,int b, float c)
{
       cout<<"The values entered are:"<<endl;
cout<< a << b;
       cout<<"The area is:"<<endl;
       cout<< c;
}
Creating a header file and defining its function in another file is easy. I need help regarding the logic which is to be made.
Firstly, there are issues with your spaces.

As for making multiple files, what you make in the .h files are interfaces, not definitions. If you remove all the definitions, you'll be left with a clean list of functions from which you can guess what a class does. In your case, it'd be something like.

Code:
class shape
{
private:
int a,b;
public:
shape();
float area_r();
float area_t();
void getValues(); //It's better to use a constructor for this

}'
Then you make the defintions in the .CPP file. And you need to use header guards(#ifndef and #def ), especially if you there is more than 1 file. In the .cpp file, you'll define
Code:
shape::shape() {\\stuff}

float shape::area_r(){\\definition}

float shape::area_t(){\\definition}
If your code is working in a single file, cut-pasting the definitions to the .cpp file shouldn't be an issue, make sure to include the .h file at the top. You might have to include iostream and using namespace std again as well depending on the situation.
 
General chit-chat
Help Users
We have disabled traderscore and are working on a fix. There was a bug with the plugin | Click for Discord
  • No one is chatting at the moment.
  • Necrokiller Necrokiller:
    The only valid thing from his pov he said in the video is AC dead since Black Flag. According to woke police that game was woke too. Welsh man in West Indies. So atleast he's consistent I guess lol
    Link
  • Link
  • XPremiuM XPremiuM:
    Necrokiller said:
    It's based on an actual real life person so I don't think the woke police have a valid case here.
    Nope. They have a very valid case. The above video explains it all.
    Link
  • Necrokiller Necrokiller:
    It's based on an actual real life person so I don't think the woke police have a valid case here.
    • Like
    Reactions: SolitarySoldier
    Link
  • XPremiuM XPremiuM:
    Meanwhile Ghost of Tsushima PC version is out now. Looks 100 times better than ASS Creed already.
    Link
  • XPremiuM XPremiuM:
    Did y'all see the new Assassin's Creed trailer? They finally made a AC set in Japan & then they put a negro as the male protagonist. Ubisoft is taking cues from Disney, and it isn't gonna end well for them, just like Disney. Go woke, go broke!
    Link
  • Necrokiller Necrokiller:
    First Fallout 4 update and now this 🤡
    Link
  • Necrokiller Necrokiller:
    MS and Bethesda continuing their streak of massive Ls 😬
    Link
  • Link
  • funky funky:
    Hello
    Link
  • NaNoW NaNoW:
    by closing down good studios
    Link
  • NaNoW NaNoW:
    well he is breaking barriers
    • Like
    Reactions: KetchupBiryani
    Link
  • iampasha iampasha:
    SolitarySoldier said:
    Phil keeps talking about breaking barriers to gaming, making it accessible on all platforms yada yada, while killing competition and creativity at the same time. the fact that i actually believed him for a second lol
    guys the biggest yapper in the Industry right now. All he do is yap
    Link
  • Necrokiller Necrokiller:
    Phil should be held responsible for this shitfest too, just like Sarah, but it's highly likely that these decisions are coming from Satya. And this isn't even the end of it. More closures are coming.
    Link
  • SolitarySoldier SolitarySoldier:
    if we are moving towards more and more popular trash across platforms that make billions for companies, I'm happy with all the barriers and exclusivity because at least that brings some pressure to create good stuff.
    Link
  • SolitarySoldier SolitarySoldier:
    Phil keeps talking about breaking barriers to gaming, making it accessible on all platforms yada yada, while killing competition and creativity at the same time. the fact that i actually believed him for a second lol
    Link
  • SolitarySoldier SolitarySoldier:
    "These changes are not a reflection of the creativity and skill of the talented individuals at these teams or the risks they took to try new things" ... seems to me that's exactly what it is
    Link
  • SolitarySoldier SolitarySoldier:
    why make good games when u can just buy everyone and shut them down lol
    Link
  • XPremiuM XPremiuM:
    I'm gonna say one last time, F*** Microsoft to infinity!
    Link
  • XPremiuM XPremiuM:
    Microsoft deserves all the hate they can get. Seriously i can't explain how much i want to curse them out.
    Link
  • XPremiuM XPremiuM:
    They could've sold the studios instead of closing them, but the nazi bastards just didn't want competition down the road.
    Link
  • Link
  • XPremiuM XPremiuM:
    F*** Microsoft, and F*** their fanboys.
    Link
  • XPremiuM XPremiuM:
    What's the f*** is wrong with them? I mean really? Have they completely lost it? F***ing retards.
    Link
  • XPremiuM XPremiuM:
    So i just found out that f***ing s***bag Microsoft shut down Arkane Studio (makers of the brilliant Dishonored series) and Tango Gameworks (makers of the iconic The Evil Within series), among some other studios. I just want to say a giant F*** Y**! to Microsoft. THEY'VE F***ED UP BIG TIME this time.
    Link
    Necrokiller Necrokiller: The only valid thing from his pov he said in the video is AC dead since Black Flag. According to...