Thursday, December 21, 2006

Chapters :-
1.Introduction to C and C++
2.A Simple C program
3.How we can play with C
4.Magic of loops
5.Condition Loops
6.Switch statement and cases
7.Do-While Loops
8.Reference Variable
9.Array
10.Two Dimensional array
11.Funtion
12.Pointer
13.Function Overloading
14.Prototype
15.Default Argument
16.Constant Arguments
17.Class
18.Factorial
19.Bubble sorting
20.Selection sorting
21.All programs

CLASS AND OBJECTS

CLASS

The basic difference between C and C++ is class. It is somewhat difficult to understand in first sight. But I assure you that it is very easy to understand. Read all the material, you will find each and every thing difficult initially but gradually your ride will become smother.
It is very important feature of object oriented programming. Class is used in c++ to create user defined data. Class is a technique to combine object functionality and properties at one place. By using it we can bind different data member and method in one unit. After that we use make the object of a class and use it in the program.
In simple word we can say to represent any object of this world in the program is called class.

Syntax
Class class-name
{
vis mode : (private)
Data member(variable)
Member function (fun)
Vis mode : (public)
Data-member(variable)
Member fun(fun methods)
};

In class the variable which is used to store the importance of object is called Data member. And for performing different types of operation on a object, function which is used is called Member function.


Visibility Mode

They are two types of visibility mode:-
a. Private
b. Public

Private :- This is class default mode. When we without writing any visibility mode define some variables it will always goes in Private. We cannot use class private members outside the class. They can be used with the class members.

Public :- To make a member type of public we used public visibility mode. It can be used outside class also. Usually Data member is made in private and member function made public. I will define it later the reason behind it.

Program

Return to main menu

Monday, December 18, 2006

Output of reference variable

If we are taking the value of a=10 than output will be
10
10
100
100

Now you may ask how?
Because we are taking r as a reference variable of a, whatever we change in r the change automatically transmit to a. To understand it more clearly please try to change the value of both a and r in the program. I bet after changing two or three variables in this program you have not any question if still there is any question you may email meat famoustar2001@yahoo.com

Playing with loops

There are three interesting questions of “for” loop. I promise you after playing with these questions you will never face any problems in" for" loop :-

Write a program for printing following results ?
Question 1.

*****
****
***
**
*

Question 2.

The toughest one
1
01
101
0101
10101


I will add more questions and solutions soon. Try to solve it out and if you have solved it please leave a comment on main page so everyone able to read it.

Return to main page.

Saturday, December 16, 2006

DO-WHILE LOOP


# include

.................................

....................

...................................

/*do {

body...........

...............

}

while(condition);

*/

}


WHILE LOOP

while(condition) {

command........

}


Now i am taking some examples of do and while....and i am also telling you where to use it..

let make a program to print 10 numbers in ascending order and i am taking i=1.


# include

# include


void main()

{

int i=1;

do {

cout<

i++;

}

while (i<=10);

getch();


}


now many of you are thinking that why we are using do when we can perform this operation by just while loop. yes you are right but you can perform this all printing by "for" loop too but i just wanna tell you that my main motive is to explain how to use do-while loop.


Now qution arises :-


Q1 How do-while loop works?

Ans1 Do -> Use as a must work loop. In simple words we can say this loop will run one time we want it or not it does'nt make any difference.


Q2 How many programs use do-while loops?

Ans2 (a)Factorial->Program ( please try once on your own)

(b)Prime number->program

(c)Fabonic series ->Program

(d)Reverse Number->program

(e)Armstrong ->program


A simple c program :-

# include stdio

# include conio

void main()

{

printf("5");

}

Do you beleive this simple C program covers almost 10% of c.

Now three qution arises :-

1. what is conio.h and stdio.h ?

2. what is void main() and why we are using it ?

3. what is printf option?

To get the answers of these three qution we will perform some tricks :-

1. We remove (# include conio.h ) from the program. Now after removing conio.h we observe that program is still running and not showing any error.Therefore qution arises that why are we using it? yes in this program we does'nt require it but we are playing a secure game, in simple words i wanna say that it is used in many programs so why take risk! And don't worry i will explain it complete in next chapters.

We remove ( # include stdio.h ) opps this time program is showing error =>undefined function printf. It clearly tells us that stdio is related to printf statement and it is used to define printf. So by doing this we get our second answer.

2. Now, i wanna tell you that we are using void main because our compiler use it as a main gate of the program.We usually think that program start from #include files ....NO i waanna tell you that this is misconception. Compiler always search main function in the program and if it does'nt find it program becomes unexecutable.

3. Now you are thinking that what is the use of printf function. I just wanna tell you that you will understand it better if use you will use different things in printf for eg in my program i am using 5 in printf you can use any statement at the place of 5.

look here =>

printf("i am hero"); or printf("i am hero heralal no.1"); or printf("i proud to be indian"); anything you want.....and i want you to play with it. As much as you will play as much you will enjoy. But remmember the format (" "); now please don'nt ask why?

FACTORIAL


# include <-------------------------header file

# include <-------------------------header file

void main()<--------very important function this is just like main gate of any program

{<-----------------------------------intial bracket for main function

int n,fac,i=2;<---------------------------------i am taking three variables n,fac and i as integers

clrscr();<---------------this is used to clear screen .............use it or not all depends on u.

cout<<"Enter any number";<------------u can understand it in 'c' we will use printf("enter any number");


cin>>"n";<-----------------taking a value of n in c we use scanf("%d",&n);

fac=n;

while(n>0) {

i=i*n;

n--;

}

cout<<"n factorial of "<

getch();

}


Thursday, December 14, 2006

Function Overloading

Jab hum kisse program mein ek hi naam say do ya do say aadhik function banaye tho yeh function overloading kehlatii hai. isme function ka naam tho same hota hai lekin unki argument list alag alag hoti hai.
Eg

Do-While Loop

DO-WHILE

Monday, December 11, 2006

Complete C++ tutuorial

Hello Friends,
Are you finding C++ difficult ?
Do you want to learn C++ & C.
Then you are at right place this is Computer guru (CG) your online dost.If you find C and C++ difficult, then my message for you is that if you can learn languages like English,French or Hindi , you would easily simple computer languages like c or c++.
Before We start, you should have some basic knowledge of C. If you don't have than don't worry i am here to help you and after reading some text you will start understanding each and every thing.
And last but not least,please practice because practice makes a man perfect and if you face any problems i am always there to help you.

GET STARTED

Monday, December 4, 2006

C & OTHER COMPUTER LANGUAGES

# include
# include