The Official Programming Thread

hash94

PrO GameR
Aug 23, 2009
1,209
0
41
Well, I am taking BS Chem Eng, But went through basic C++ programming.

And the thing is that programming fascinated me a lot, i want to learn more on this,basically self study.

So can someone guide on what should i start learning and where, and could this added skill of programming help in future?
 

salman09

Proficient
Jul 24, 2010
846
0
21
Lahore
so guyz here I just started doing BS CS from NUST
our teacher refferred to different books for C language including
Harvey_Dietel_-_C_How_to_Program_6th_Edition.pdf
Robert_Sebesta_-_Concepts_of_Programming_Languages.pdf
Steve_Oualline_-_Practical_C_Programming_3rd_Edition.pdf
and C for dummies

so guyz need some suggestion which book should I start with and in order to improve my programming skills what should be my pattern of studying
as I am a beginner and starting from the scratch and in the end of semester 1 i wanted to be a pro in C language


 

babarhyd

*nix GURU
Sep 10, 2010
293
0
21
Hyderabad
so guyz here I just started doing BS CS from NUST
our teacher refferred to different books for C language including
Harvey_Dietel_-_C_How_to_Program_6th_Edition.pdf
Robert_Sebesta_-_Concepts_of_Programming_Languages.pdf
Steve_Oualline_-_Practical_C_Programming_3rd_Edition.pdf
and C for dummies

so guyz need some suggestion which book should I start with and in order to improve my programming skills what should be my pattern of studying
as I am a beginner and starting from the scratch and in the end of semester 1 i wanted to be a pro in C language


Dietel. That's where you need to start from.
 

Hassan

lethargic procrastinator
Jun 20, 2009
6,520
0
41
3 miles from the nearest bus stop
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.
I asked help regarding the logic. I know all that stuff you mentioned
 

Newton

Well-known member
May 17, 2009
2,223
0
41
Lahore, Faisalabad
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
Spoiler: show
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.
are you getting compile time errors or is the output not as you expected it to be?
 

MegamanEXE

Well-known member
Dec 7, 2007
1,958
1
43
28
Islamabad
Dietel. That's where you need to start from.
Dietel is a terrible book to start from o_O Kinda intimidating for someone who has never seen a programming language before.
[MENTION=13101]Hassan[/MENTION] What seems to be the issue then? BTW a switch statement is much better for stuff like menus.
 

Arhamsaeed

Intermediate
Apr 7, 2012
193
0
21
Karachi
Assalamo Alaikum guys, I've absolutely zero knowledge of programming kindly suggest me which language schould I learn. And also suggest some books. Thanks.

Sent from my HTC Ruby using Tapatalk 2
 

winchester khan

Well-known member
Dec 31, 2013
1,116
0
41
Assalamo Alaikum guys, I've absolutely zero knowledge of programming kindly suggest me which language schould I learn. And also suggest some books. Thanks.

Sent from my HTC Ruby using Tapatalk 2
I would suggest C++,PYTHON AND JAVA .....Python is good for beginners ...
 

gow3

Well-known member
Jan 10, 2010
1,053
0
41
Depends on how much time you're willing to invest. If you have a lot of time, I'd recommend python for a few days and then moving to C++ (Just a preference because I make iOS Applications so I'll assume you want to do the same. Learn C++, learn objective-c, start making apps).
 

MegamanEXE

Well-known member
Dec 7, 2007
1,958
1
43
28
Islamabad
Honestly though, I borrowed a Python book from my uni's library. Even though I had a very good grasp on programming concepts and coding, I felt Python isn't really as beginner-friendly as I thought it'd be. Throwing terms like Frozen Binaries and Interpreters (alongwith others I can't remember :p) at amateurs isn't a good plan. I'd still recommend C/C++.
 

Gizmo

Expert
May 6, 2009
12,863
2
42
Lahore
Man, don't go for beginner friendly stuff, just get a good book that teaches C++, once you learn that alongwith all the basic programming concepts then you can go for any language you want. There's a reason why most Unis start sutdents off with C++. it's a good place to start.

I started learning C++ just a few months ago and before that I had zero programming experience other than a few programs I made in BASIC for school which I don't even remember anymore. It's not that hard.
 

puppet

Well-known member
Sep 30, 2013
2,169
0
42
Man, don't go for beginner friendly stuff, just get a good book that teaches C++, once you learn that alongwith all the basic programming concepts then you can go for any language you want. There's a reason why most Unis start sutdents off with C++. it's a good place to start.

I started learning C++ just a few months ago and before that I had zero programming experience other than a few programs I made in BASIC for school which I don't even remember anymore. It's not that hard.

i dont know wtf is beginner friendly , seriously i mean seriously C++ is the language i learnt very first as a programmer , and instead of learning it from online tutorials and examples indeed book is best , examples and online sites are just extras for me or bonus content you guys can say , once you complete OOP then you can create mini projects to test the skills later learn any language , maybe later you dont need a book only online courses would be enough but very first time you need proper classes you need a regular teacher you need a good book and time to practice what have you learnt :)


programming is a very hard thing if you got no passion for it , if you do so it is the the fun , as this field i mean developing things for me is the most enjoyable work for me and i seriously love to code more than se* :laugh1:
 

Gizmo

Expert
May 6, 2009
12,863
2
42
Lahore
You don't really need a teacher that bad, just a good book + the will to give it some time and practice IMO. :tv:
 
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.
    NaNoW NaNoW: ....