Posts

Lesson 10

                                              Structures & Unions 1. Structure Definition 2. Structure Declaration 3. Initialization & Accessing Structure Members 4. Nesting of Structures 5. Union: Definition, Declaration & Initialization 6. Arrays of Structure & Unions 1. Structure Definition A struct in the C programming language (and many derivatives) is a composite data type (or record) declaration that defines a physically grouped list of variables under one name in a block of memory, allowing the different variables to be accessed via a single pointer or by the struct declared name which returns the  2. Structure Declaration A "structure declaration" names a type and specifies a sequence of variable values (called "members" or "fields" of the structure) that can have different types. ... Structures in C are similar to the types known as "records" in other languages. 3. Initialization & Accessing Structure Members C langu

Lesson 9

                                             Arrays 1. Concept of Array 2. One Dimensional Array 3. Two Dimensional Array 4. Multi-Dimensional Array 1. Concept of Array An array is a collection of data items, all of the same type, accessed using a common name. A one-dimensional array is like a list; A two dimensional array is like a table; The C language places no limits on the number of dimensions in an array, though specific implementations may 2. One Dimensional Array A one-dimensional array is a structured collection of components (often called array elements) that can be accessed individually by specifying the position of a component with a single index value. Syntax: data-type arr_name[array_size]; Initialization of One-Dimensional Array in C An array can be initialized at either following states: 1. At compiling time (static initialization) 2. Dynamic Initialization Compiling time initialization: The compile-time initialization means the array of the elements are initialized

Lesson 8

                          Control Flow - Looping 1. while Statement 2. do while Statement 3. for Statement 4. break Statement 5. continue Statement 6. goto Statement 1. while Statement A while loop in C programming repeatedly executes a target statement as long as a given condition is true. Syntax The syntax of a while loop in C programming language is − while(condition) {    statement(s); } Flow Diagram   2.Do while Statement Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop in C programming checks its condition at the bottom of the loop.A do...while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time. Syntax The syntax of a do...while loop in C programming language is − do {    statement(s); } while( condition ); Flow Diagram    3.For Statement A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Synt

Lesson 7

                          Control Flow - Looping 1. while Statement 2. do while Statement 3. for Statement 4. break Statement 5. continue Statement 6. goto Statement 1. while Statement A while loop in C programming repeatedly executes a target statement as long as a given condition is true. Syntax The syntax of a while loop in C programming language is − while(condition) {    statement(s); } Flow Diagram 2.Do while Statement Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop in C programming checks its condition at the bottom of the loop.A do...while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time. Syntax The syntax of a do...while loop in C programming language is − do {    statement(s); } while( condition ); Flow Diagram 3.For Statement A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Syntax T

Lesson 6

                      Control Flow – Decision Making 1. Types of Flow Control Statements 2. if Statement 3. if...else Statement 4. if...else if Ladder 5. switch case Statement 1.Types of Flow Control Statements There are four types of control statements in C: • Decision making statements. • Selection statements. • Iteration statements. • Jump statements. 2.if Statement An if statement consists of a Boolean expression followed by one or more statements. Syntax The syntax of an 'if' statement in C programming language is − if(boolean_expression) {    /* statement(s) will execute if the boolean expression is true */ } If the Boolean expression evaluates to true, then the block of code inside the 'if' statement will be executed. If the Boolean expression evaluates to false, then the first set of code after the end of the 'if' statement (after the Closing curly brace) will be will be executed.C programming language assumes any non-zeroFlowDiagram 3.if...else S

Lesson 5

                                                  Operators and Expressions     Arithmetic Operators Relational Operators Logical Operators Bitwise Operators Assignment Operators Miscellaneous Operators Operator Precedence and Associativity                     Type Conversions in Expression  Arithmetic Operators The arithmetic operators perform addition, subtraction, multiplication, division, exponentiation, and modulus operations. Relational Operators In computer science, a relational operator is a programming language construct or operator that tests or defines some kind of relation between two entities. ... In languages such as C, relational operators return the integers 0 or 1, where 0 stands for false and any non-zero value stands for true   Logical Operators     Operator Description Example && Called Logical AND operator. If both the operands are non-zero, then the condition becomes true. (A && B) is false. || Called Logical OR Operator. If any of the tw

Lesson 4

                                                                           C Statements 1. Structure of a C program 2. Errors in a C program 3. Simple and Compound statements 4. Input /Output statements 5. Formatted I/O 6. Non-Formatted I/O 7. Storage Classes structure of a c program Before we study the basic building blocks of the C programming language, let us look at a bare minimum C program structure so that we can take it as a reference in the upcoming chapters. Hello World Example A C program basically consists of the following parts − • Preprocessor Commands • Functions • Variables • Statements & Expressions • Comments Let us look at a simple code that would print the words "Hello World" − #include <stdio.h> int main() {    /* my first program in C */    printf("Hello, World! \n");    return 0; } Let us take a look at the various parts of the above program − · The first line of the program #include <stdio.h> is a pr