## Articles for 'C / C++'

### C / C++ »

[24 Jan 2012 | No comments | 2,299 views ]

We can understand this just with an example:

for(x=1; x<10; x++){ if(x==5) break; //exits from loop } printf(?x = %d ?, x); // this will print ?x=5? x=3; while(x<10){ if(x==5) continue; //continue with next iteration of the loop printf(?...

### C / C++ »

[6 Sep 2011 | No comments | 1,733 views ]

Switch is a selection structure just like if, if/else. It is not a repetition structure. Important points of using switch:
? We use switch while checking one variable with different outcomes with more than one value.

? It should be equality. Comparison (< or >) won’t work with switch.

? In switch, only integer can be used, not other types. But character is also acceptable, because as you know, character has also an integer value which is ASCII code. So we can say,

### C / C++ »

[5 Sep 2011 | No comments | 1,666 views ]

After a long time, i have started to continue this course. Because i got some mails which want me to complete this course. Even if there is someone who benefits this course, it is enough for me to be willing to continue. Let’s continue then;)

Do/While

Let’s try one example with 3 different loops that we have learned before. Also this example will remind us how to use loops.

(1) int x=1;

while(x<=10){ ...

### C / C++ »

[7 May 2011 | 2 Comments | 2,114 views ]

The Negation Operator (! ? NOT)
x=3;
if(! (x>10) )
printf(?%d?,x); //it will print ?3?.
if(!0)
printf(?hey?); //it will print ?hey?.
if(!x)
printf(?%d?,x); //it will print nothing.

!true=false
!false=true

3 Steps Which We Should Follow

1- Declare the input and use scanf initialized before while
2- Use the input in condition while and compare it with sentinal value
3- Change the input using scanf before the end of the loop

### C / C++ »

[25 Dec 2010 | 2 Comments | 1,939 views ]

Pre-increment and Post-increment

Pre-increment changes the value of the variable, and then makes the calculation or processes which should be done. (It?s written like this: ?++x ?)

Post-increment makes the processes and then changes the value of the variable. (It?s written like this: ?++x ?)

Decrement versions of these are the same. (?–x? or? x–?)

int x=3;

printf(?%d?, ++x); //it will change the value of x to 4 and then print 4…

### C / C++ »

[18 Dec 2010 | No comments | 1,756 views ]

While Loops

*Counter Controlled Loops:

Steps that we should follow:

? 1- Declare and initialize a counter

? 2-Use the counter in the condition part of while

? 3-Change the value of the counter inside the loop (increment or decrement)

¤ These 3 steps must be used in our program, else it means there is something wrong.

### C / C++ »

[17 Dec 2010 | No comments | 1,521 views ]

?OR? and ?AND? Conditional Operators

In C, there is not any condition like that: if(00)

statements;

this means if the value is between 0 and 25, then run these statements.

True && True= True

True && False= False

False && False = False

### C / C++ »

[29 Oct 2010 | 5 Comments | 2,300 views ]

Write a program that enters a final grade of student and prints if the student passed or failed. (40 and above passed)

#include

int main(){

(continues)…

### C / C++ »

[3 Aug 2010 | 1 Comment | 2,438 views ]

They are used to compare some values and operate according to result.

The result can be true or false.

* If the condition is true, it operates everything in if statement.
* If the condition is false, it skips whole if statements and continue.

We can build conditional statements in two forms:

### C / C++ »

[3 Aug 2010 | 4 Comments | 1,882 views ]

Let’s continue with calculation in C!
First of all, we should know about order of mathematical operations. Basicly, we can say the order is like that:
1) ( ) paranthesis
2) * (product), / (division) , % (remainder of division)
3) + (summation), – (difference)
If operations are in the same order ( like + and – ), than the priority belongs to one that comes first.
Example;
int x= 5 * 4 / 2 + ( 4 + 2 );
If we print, it will find x …