Skip to main content

C tutorial- basic

C TUTORIALS-00

INTRO TO C PROGRAMMING LANGUAGE
PROGRAMMING LANGUAGE WAS INVENTED BY 'DENNIS RITCHIE'.
TODAY WE WILL DISCUSS MANY THINGS ABOUT  BASICS OF C PROGRAMMING LANGUAGE.
SO LET'S GET STARTED !
TOPICS COVERED  IN THIS SECTION-
1. BASICS INTRO TO ELEMENTS OF C
2.OPERATORS
3. CONDITIONAL STATEMENTS
4. LOOPS


1.ELEMENTS OF C 

A C program basically consists of the following parts −
  • Preprocessor Commands- HEADER FILES CONTAINS PRE PROGRAMMED FUNCTION
  • Functions - PROGRAM STARTS FROM MAIN FUNCTIONS UNDER WHICH OTHER USER DEFINED FUNCTIONS CAN BE USED
  • Variables-  ANYTHING WHICH CAN BE  CHANGED IN ENTIRE PROGRAMS , VALUE IS NOT FIXED
  • Statements & Expressions
  • Comments


2. operators


  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Assignment Operators
  • Misc Operators
  • && (logical AND)
    (x>5)&&(y<5)
    It returns true when both conditions are true
    || (logical OR)
    (x>=10)||(y>=10)
    It returns true when at-least one of the condition is true
    ! (logical NOT)
    !((x>5)&&(y<5))
    It reverses the state of the operand “((x>5) && (y<5))”
    If “((x>5) && (y<5))” is true, logical NOT operator makes it false
  • BELOW ARE THE BIT-WISE OPERATORS AND THEIR NAME IN C LANGUAGE.

    1. & – Bitwise AND
    2. | – Bitwise OR
    3. ~ – Bitwise NOT
    4. ^ – XOR
    5. << – Left Shift
    6. >> – Right Shift










3. conditional statements





Exp1 ? Exp2 : Exp3;
Where Exp1, Exp2, and Exp3 are expressions. Notice the use and placement of the colon.
The value of a ? expression is determined like this −
  • Exp1 is evaluated. If it is true, then Exp2 is evaluated and becomes the value of the entire ? expression.
  • If Exp1 is false, then Exp3 is evaluated and its value becomes the value of the expression.

4. loops



Loop NameSyntax
for
for (exp1; exp2; expr3)
{ statements; }
Where,
exp1 – variable initialization
( Example: i=0, j=2, k=3 )
exp2 – condition checking
( Example: i>5, j<3, k=3 )
exp3 – increment/decrement
( Example: ++i, j–, ++k )
while
while (condition)
{ statements; }
where, 
condition might be a>5, i<10
do while
do statements; }
while (condition);
where,
condition might be a>5, i<10

1break statement
Terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch.
2continue statement
Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
3goto statement
Transfers control to the labeled statement.

SOME BASIC PROGRAMS FOR START


 2. sum of natural nos


3.prime or not


 



3. bitwise 'and'



 NEXT TOPICS---- ARRAYS, STRING AND POINTERS

STAY TUNED FOR UPDATES LIKE FOR MORE
FOR VIDEO GUIDE REFER 


Comments