C/C++ Beginner's Guide and Post Basic Questions here

kunalht

In the zone
ok thank you.
Going to buy that book from flipkart.
& after completing that book, will i be able to make small games & Unreal devlopment (UDK) games??
 

Nerevarine

Incarnate
uhh.. you will find, game designing is a LARGE LARGE part of programming.. learning C is just scratching the surface..
You also might want to start with unity, if you plan on game development.. its a lot more noob friendly than UDK
 

rohitshubham

Ambassador of Buzz
It does not encourage to code imo. Same with all indian authored books including "Let Us C".
I strongly advice beginners to stay away from these as there are better materials and books out there.

"Head First C" is the best example.
yup, you are correct, they do not encourage to code...and their motive is mainly to teach students how to use syntax of the language...
however i feel that indian authors are more relevant for most of the students.. you see the level of english they use for explaining is kinda tough for most of the indian students while the indian authors write in plain english only few students can understand foreign authors easily or else they are very elaborate and most of the students don't have time for that much research ...this is the case for many books like physics/chem/electronics etc.
BTW have you read "C++ object oriented programming by debasis jana"... i am currently reading it along with "thinking in C++"... its a good read although a bit technical approach has been followed in former one...
 

vickybat

I am the night...I am...
yup, you are correct, they do not encourage to code...and their motive is mainly to teach students how to use syntax of the language...
however i feel that indian authors are more relevant for most of the students.. you see the level of english they use for explaining is kinda tough for most of the indian students while the indian authors write in plain english only few students can understand foreign authors easily or else they are very elaborate and most of the students don't have time for that much research ...this is the case for many books like physics/chem/electronics etc.
BTW have you read "C++ object oriented programming by debasis jana"... i am currently reading it along with "thinking in C++"... its a good read although a bit technical approach has been followed in former one...

Well rohit that is a plain misconception. There is nothing like plain and advanced english. It depends on the author how lucrative and simple he can be while presenting the stuff along with some solid and real life examples. This is where Indian authors mostly fail and always rely on same old "toy programs". At least i feel that way. Well about other subjects, its a different story as the curriculum are mostly different. For computer science subjects, its best to avoid Indian authors, unless a real gem is discovered. Till now, it hasn't been, atleast i haven't seen one.

I'm not a C++ programmer but Java and have followed head first java, Core Java (Cay Horstmann) , Data Structures in Java (Robert Lafore) and also planning to read Effective Java (Joshua Bloch).
I couldn't find a single Indian authored Java book that can hold a candle to the ones mentioned above.

About C++, "thinking in c++" by Bruce Eckel is one of the best books out there afaik. He has also authored thinking in java, but i never followed it.
Can't comment on the c++ book you mentioned cause of the reasons mentioned above (me not being a c++ programmer).

For a C++ absolute beginner planning to get hold of the syntax and trying to delve into the world of oop for the first time, the following is a great choice imo.
Its very very simple and is perfect for engg. students to pass semester exams with good marks and grades. It has lots and lots of examples with line by line explanation. Very effective for students who don't have time to spend more towards coding due to pressure from other subjects in a semester.

*pearson.vrvbookshop.com/book/learning-c-programming-concepts-sham-tickoo/9788131716533

ok...
thanks for help.
ordered head first C from flipkart...

Congrats mate :). Getting hold of the syntax alone is not enough to be an effective programmer but rigorous practice.
That is the only way to be a good programmer and there are no shortcuts here.

Happy coding and keep practicing.
 
Last edited:

kunalht

In the zone
yes!! :razz:

& which IDE should I use?
dev c++ or code blocks or any other?
In our college, they still use TC but it's not supported in my windows 8 and also it is very old.
which should i use?
& if i use notepad++, then how to compile & run c program?
 
Last edited:

vickybat

I am the night...I am...
yes!! :razz:

& which IDE should I use?
dev c++ or code blocks or any other?
In our college, they still use TC but it's not supported in my windows 8 and also it is very old.
which should i use?
& if i use notepad++, then how to compile & run c program?

Use code blocks eyes closed and avoid TC at all costs.

Notepad++ is a text editor and not a compiler. You can use it to highlight the code to understand it better before moving to the IDE.
You can directly code in code blocks editor too.
 

Nerevarine

Incarnate
another +1 from my side towards codeblocks.. Your school may force you to use TC but stay adamant and use codeblocks, atleast in your own pc
 

rohitshubham

Ambassador of Buzz
yes!! :razz:

& which IDE should I use?
dev c++ or code blocks or any other?
In our college, they still use TC but it's not supported in my windows 8 and also it is very old.
which should i use?
& if i use notepad++, then how to compile & run c program?
TC is vintage.....code::blocks is the best one out there and i use it myself... In fact my college now recommend code::blocks due to excessive lobbying by me ... actually they used devC++ and i literally forced them to move out of that though devc++ is fine enough for semester exams.
 

rohitshubham

Ambassador of Buzz
can someone please explain me operator overloading with a simple program...i mean explain the program too as how it is working...
 

ashs1

Padawan
hi Guys.. I have just started learning the C program recently. Teachers have advised me to go for books from balaguruswamy & "c in depth" by shrivastva. Judging from some of the previous posts, it looks like most of you guys prefer to stay away from it. Can you guys suggest a good book for beginners ? This is the first time i am learning a programming language. :)
Thanks.
 
can someone please explain me operator overloading with a simple program...i mean explain the program too as how it is working...

Do you understand the concept of function overloading? Operator overloading is similar to that, but with a few constraints:

> You cannot define new operators.
> You cannot change the precedence and priority of operators.
> You cannot change the arity of operators.


Just like a function call, a reference to the object which invokes the operator is implicitelly passed to the operator bosy. This reference is called the 'this' operator and it can be used to access the object which invoked the operator.



this will return an error because no definitation of the plus operator is defined for class a and class b;

Code:
#include <iostream>
class a
{...};   //skipping the class definition

class b
{...};   //skipping the class definition

int main()
{
a obj1;
b obj2;
cout << obj1 + obj2;

return 0;
}


Code with overloaded operator
Code:
#include <iostream>
class a
{public:
int num;

friend int operator +(b obj2);
};

class b
{public:
int num;
};

int operator +(b obj2
{
    return (this.num + obj.num);
}

int main()
{
a obj1;
b obj2;
cout << obj1 + obj2;

return 0;
}

Here, 'a' is invoking the 'operator +'. However, the if I wrode b+a instead of a+b, it would still crash as it would be 'b''s responsibility to invoke the + operator, but no definition of + exists for class b.
 

rohitshubham

Ambassador of Buzz
Do you understand the concept of function overloading? Operator overloading is similar to that, but with a few constraints:

> You cannot define new operators.
> You cannot change the precedence and priority of operators.
> You cannot change the arity of operators.


Just like a function call, a reference to the object which invokes the operator is implicitelly passed to the operator bosy. This reference is called the 'this' operator and it can be used to access the object which invoked the operator.



this will return an error because no definitation of the plus operator is defined for class a and class b;

Code:
#include <iostream>
class a
{...};   //skipping the class definition

class b
{...};   //skipping the class definition

int main()
{
a obj1;
b obj2;
cout << obj1 + obj2;

return 0;
}


Code with overloaded operator
Code:
#include <iostream>
class a
{public:
int num;

friend int operator +(b obj2);
};

class b
{public:
int num;
};

int operator +(b obj2
{
    return (this.num + obj.num);
}

int main()
{
a obj1;
b obj2;
cout << obj1 + obj2;

return 0;
}

Here, 'a' is invoking the 'operator +'. However, the if I wrode b+a instead of a+b, it would still crash as it would be 'b''s responsibility to invoke the + operator, but no definition of + exists for class b.
thanx. :)
 

Nerevarine

Incarnate
Code:
#include <stdio.h>
int main()
{   
    char C [3][3];
    int C1[3][3];
    
    int i, j; int m[8];int n=0; int k=0;
    int trigger=0;
    void check()
    {
        for(i=0;i<9;i++)
        {
            m[i]=0;
        }
        for(i=0;i<3;i++)//ACROSS ADD
            {
                for(j=0;j<3;j++)
                    {
                        m[i]=m[i]+C1[i][j];
                    }
            }
        for(i=0;i<3;i++)//DOWN ADD
            {
                for(j=0;j<3;j++)
                    {
                        m[i+3]=m[i+3]+C1[j][i];
                    }
            }
        //DIAGONALS ADD
        m[6]=C1[0][0]+C1[1][1]+C1[2][2];
        m[7]=C1[0][2]+C1[1][1]+C1[2][0];
        
        for(i=0;i<8;i++)
            {
                if(m[i]==3)
                    {trigger=1;
                    }
                if(m[i]==6)
                    {trigger=2;
                    }
            }
        
    }
    void display()
    {
        printf("\nState of Game:\n");
        for(i=0;i<3;i++)
         {
             for(j=0;j<3;j++)
                {
                    printf("%c  ",C[i][j]);
                }
            printf("\n");
         }
    }
    printf("Welcome to my Tic Tac Toe game\n");
    while(k<9)
    {   if(n%2==0)
        {
        printf("\nPlayer 1 Input : X at desired index location");
        printf("\ni:");
        scanf("%d",&i);
        printf("\nj:");
        scanf("%d",&j);
        C[i][j]='X';
        C1[i][j]=1;
        //CHECK
        display();
        check();
        n++;
        if(trigger==1)
          {
              printf("Player 1 wins");
              break;
          }
        }
        if(n%2==1)
        {
        printf("\nPlayer 2 Input : X at desired index location");
        printf("\ni:");
        scanf("%d",&i);
        printf("\nj:");
        scanf("%d",&j);
        C[i][j]='O';
        C1[i][j]=2;

        //CHECK
        display();
        check();
        n++;
        if(trigger==2)
          {   printf("Player 2 wins"); 
              break;
          }
        }
        k++;
    }
    return(0);
}
pls check for run time error..
its a basic 2 player tic tac toe program
 
Top Bottom