C Programming Language

This tutorial covers basic concepts of  C. Topics covered are Basics of C, Constants, Data  types, Operators, Control Structures, Arrays, Functions, pointers, structure, union, data file handling, characters and strings along with different libraries.

Lessons

Introduction to C Language

Preview

Complexity: Standard

Introduction to C Language C Language is a high level programming language developed at “AT & T’s Bell Laboratories”, USA in 1972. It was written by Dennis Ritchie and Brian Kernighan. It  is also known as middle level language as it has inbuilt support for writing programs using assembly language instructions. This language was created …

What is a variable in C Language

Preview

What is a variable in C Language A variable may be defined as a named memory location i.e. a variable is the name given to a data item to refer to a memory location. The value of a variable can vary during the execution of a program. Rules to name a variable in C Language …

Constants in C Language

Preview

Complexity: Standard

Constants in C Language A Constant may be defined as a quantity whose value can’t be changed during the execution of a program. Constant can be divided into two categories. Numeric Constant Character Constant/Non Numeric Constant Numeric Constant Numeric Constant is that which can contain digits in it. Numeric constant can be categorized into two …

Data Types in C Language

Preview

Data types in C Language Data type is the way to specify the type of data as well as the range of values that can be stored in the data object or a variable. C supports three types of data types:- Primary Data Types Derived Data Types User Defined Data Types Primary Data Types Primary …

Display output in C – printf() function

Preview

Display output in C- printf() function To Display output in C, we need to use printf() function. It is also known as formatted output function. Formatted output means the output which is arranged in a particular format. The syntax of printf function() is: printf(“Control string”, arg1,arg2……); Control string specifies the format in which data is …

Read values in C- scanf() function

Preview

Read values in C- Formatted Input Formatted input means the input which is arranged in a specific format. For formatted input, scanf() function() is used. The syntax of scanf function() is: scanf(“Control string”, arg1,arg2……); Control string specifies the format in which data is to be entered by the user while inputting. Control string consists of …

C – Unformatted Output Function

Preview

C – Unformatted Output Function There are  various output functions provided by C Language. These functions are used to display the value of a variable during the execution of program. Various unformatted output functions provided by C Language are as follows:  1. putchar() It stands for put character. It is used to display value of …

C – Unformatted Input Function

Preview

Complexity: Standard

C – Unformatted Input function There are various input functions provided by C Language. These functions are used to read the value of a variable during the execution of program. Various unformatted input functions provided by C Language are as follows: 1. getchar() It stands for get character. It is used to read value of …

4 Types of Operators in C

Preview

Operators These are the symbols which are used to perform some calculation or manipulation on values which may be in the form of variables, constants or expressions in a C program. Operand It is the variable, constant or expression on which an operator performs some calculation, comparison or some other manipulation. Example    6+5       …

Increment Decrement Operators in C (++ / –)

Preview

1. Increment Operator (++) Increment operator is represented as ++. This operator is used to add one to the existing value of a variable. The variable can be of any data type including integer, real as well as character data type. It can be used in two ways:- Prefix Form In this form, the increment …

Arithmetic Operators in C

Preview

Arithmetic Operators in C Arithmetic operators are used to perform mathematical calculations in a program. Various arithmetic operators in C language are as follows: + [Addition Operator] – [Subtraction Operator] * [Multiplication Operator] / [Division Operator] % [Modulus Operator] 1. + Addition operator is represented as plus (+) sign. It is used to add values …

Relational Operators in C | Comparison operators in C

Preview

Relational Operators in C These operators are used to perform comparison between values in a program. The result of relational expression is always 0 or 1. Various relational operators in C language are as follows: < [Less Than] <= [Less Than Equal To] > [Greater Than] >= [Greater Than Equal To] = = [Equal To] …

Logical Operators in C

Preview

Logical Operators in C These operators are used to combine relational expressions. The Output: of a logical expression is always 1 or 0. Various logical operators in C language are as follows: Operator Name of Operator Purpose && Logical AND To combine two relational expressions. If any of the input is 0, Output: would be …

Bitwise operators in C | Bitwise Operator programs in C

Preview

Bitwise operators in C Bitwise operators are used to manipulate individual bits of a numeric value. There are six bitwise operators provided by C language. Bitwise AND(&) Bitwise OR (|) Bitwise XOR(^) Bitwise complement(~) Bitwise Left shift(,) Bitwise Right shift(>>) **Bitwise form of a number is obtained by converting the number into binary number. 1. …

Assignment Operators in C | Shorthand operators in C

Preview

Assignment operators in C Assignment/shorthand operators are used to update the value of a variable in an easy way. There are various assignment operators provided by C language. = += -= *= /= %= &= |= ^= <<= >>= Operator Description Example = It is used to assign some value to a variable. A=10 += …

Conditional operator in C | Ternary Operator in C

Preview

Conditional operator in C Conditional operator is also known as ternary operator. This operator is known as ternary operator because it has three operands. Ternary operator is represented as ?: . It is used to check a condition and depending upon the condition, particular instruction is executed by the compiler. Syntax: Condition? Block1: Block2; Condition …

sizeof() operator in C | comma operator in C

Preview

Special operators These operators are used for special purposes. There are many special operators provided by C language which are as follows:  sizeof()  Comma 1.  sizeof() This operator is used to find the size of a variable, constant or data type. The size returned by this operator is in terms of bytes. Program to demonstrate …

Control Structures in C | Control statements in C

Preview

Control Structures in C Control structure is also known as a control statement. Control structure is any statement of C language which can be used to control the flow of statements in a C program. By default, instructions in a program get executed in the same sequence in which they are written. Control structure can …

Simple if statement in C language

Preview

If Statement in C Language If statement is a very powerful decision making statement and it is used to control the flow of execution of statements. It is basically a two way decision making statement and it is used with a relational or logical expression. There are four types of if statement: Simple if If …

if else statement in C language

Preview

if else statement in C language  It is two way decision making  statement. In if else statement, there is only one condition and depending upon the condition, a particular set of statements will be executed. If  condition is true, one set of statements will be executed otherwise another set of statements will be executed Syntax …

Nested if statement in C Langauge

Preview

Nested if statement in C Langauge It is basically a multiway decision making statement. In nested if statement, one if statement is enclosed within another if statement. Depending upon these if statements, particular set of statements will be executed. The syntax of nested if statement is: if(Condition1) {             if(Condition2)             Statement-Block1;             else                  …

if else if ladder statement in c language

Preview

if else if ladder statement in c language This is most commonly used selection statement in C language.  It is basically a multi way decision making statement. In if else if ladder statement, there are multiple conditions one after another. Depending upon these conditions, specific sets of statements are executed. The syntax of if else …

switch statement in C | Working of switch statement in C

Preview

 Switch statement Switch statement is a multi-branch selection statement. Switch statement works with a variable or expression known as control variable or control expression. Switch tests the value of control expression/variable with a list of values known as cases of switch statement. When the value of control expression/variable matches with any of the case value, …

Jumping statements in C

Preview

Jumping Statements in C Jumping statements are used to transfer the control of program from one point to another within the program. There are three types of jumping statements provided by C language. break continue goto exit  1. break break is a keyword of C language. It is used with switch and looping statements. It …

Strings in c language with examples

Preview

Strings in c language with examples A string is a group of one or more characters enclosed within double quotes (“). A string can alphabets, digits , special characters and blank spaces. A string is always terminated with a special character called null character represented as ‘\0’. Example:  “Lovejot” , “2019” , “Rs4000”,  “ladderpython@gmail.com”  1. …

 String functions in c language with examples | strcpy, strcat, strcmp, strrev, strlen

Preview

 String functions in c language with examples There are various string functions which we can use in C Language. We need to include header file string.h in our program to use these functions in our program. Various string functions in c language are: strcpy() strncpy() strcat() strlen() strrev() strcmp() strcmpi() strncmp() strlwr() strupr() 1. strcpy() …

Array of strings in c language with examples

Preview

Array of strings in c language with examples It is actually a two dimensional array of char type. Example: char names[6][30]; In above example, names is an array of strings which can contain 6 string values. Each of the string value can contain maximum 30 characters. 1. Initialization of array of strings We can initialize an …

for statement in c language | Nesting of for in c language

Preview

for statement in c language for statement is a looping statement of c language. Looping statements are also known as iterative statements. Looping statements are used to repeat same set of statements again and again depending upon a condition. for statement is an entry controlled looping statement. It is basically used when we clearly know …

do while statement in c

Preview

do while statement in C It is an exit controlled looping statement. It is basically used when we want that loop should execute at least once. In do while statement initialization, condition and updation are performed in separate lines. The syntax of do while statement is: initialization; do { Statement-Block; updation; } while(Condition); Statement-X; do …