No | Topic |
---|---|
1 | Expression Basics |
2 | L-Value in Expression |
3 | R-Value in Expression |
404
Page not found.
Expressions in C
Constants in C
Comments in C
2.9 | What is Comment in C ? |
---|---|
2.10 | Types of Comment : Single Line | Multi Line |
2.11 | Difference Between Single and Multi Line Comment |
Types of Languages in C
2.8 | Type of Languages : |
---|---|
Low Level Language | |
Middle Level Language | |
High Level Language |
File Handling in C
No | Topic |
---|---|
17.1 | Introduction to File Handling in C Programming |
17.2 | Type of Streams | FILE structure and FILE pointer |
17.3 | Types of Files : Text | Binary |
17.4 | Opening and Defining FILE |
17.5 | File Operations : Open a File | File Opening Modes |
17.6 | File Operations : Close a File | End of File (feof / EOF) |
17.7 | Character Input/Output : Getc | Fgetc |
17.8 | Character Input/Output : Putc | Fputc |
17.9 | Character Input/Output : Fgets | Fputs |
17.10 | Formatted Input/Output : Fprintf | fscanf |
17.11 | Direct Input/Output : Fwrite | Fread |
17.12 | Random Access : Ftell | Rewind | Fseek |
17.13 | Error Handling : Possible Ways |
17.14 | Database Operation : Add Record | Display Record |
17.15 | Database Operation : Modify Record | Append Record |
17.16 | Database Operation : Delete Logically | Physically |
17.17 | File Operation Functions : fflush | rename | remove |
Union in C
No | Topic |
---|---|
16.1 | Introduction to Union |
16.2 | Declaring Union |
16.3 | Accessing Members of Union |
Structure in C
Bitwise Operator in C
No | Topic |
---|---|
14.1 | Introduction to Bitwise Operator |
14.2 | Bitwise Operator : AND | OR | XOR |
14.3 | Bitwise Operator : Left Shift | Right Shift |
14.4 | Bitwise Operator : One's Compilment |
14.5 | Concept of Masking in C Programming |
14.6 | How to use Bitwise Operator to Shift a Negative Number ? |
Preprocessor in C
No | Topic |
---|---|
13.1 | Introduction to Preprocessor : Flowchart |
13.2 | Difference Between Function and Macro |
13.3 | Tasks Performed by Preprocessor |
13.4 | Simple Substitution using #define |
13.5 | Argumented Macro Substitution using #define |
13.6 | Nested Macro Substitution using #define |
13.7 | File Inclusive Directive : #include |
13.8 | Conditional Compilation : #if | #else | #elif |
13.9 | Conditional Compilation : #ifdef | #ifndef | #undef |
13.10 | Conditional Compilation : #pragma | #pragma warn |
13.11 | Conditional Compilation : #pragma startup and exit |
13.12 | Common Mistakes while using Preprocessor |
13.13 | Applications of #define Preprocessor |
String in C
No | Topic |
---|---|
12.1 | Introduction to String Array |
12.2 | String Declaration |
12.3 | String Initialization |
12.4 | String Termination Character : NULL |
12.5 | Accepting String : scanf() | gets() | getchar() |
12.6 | Displaying String : printf() | puts() | putchar() |
12.7 | Arithmetic Operation on Characters |
12.8 | Converting String to Integer |
12.9 | String Library Functions : Strcat | Strcmp | Strcpy |
12.10 | String Library Functions : Strlen | Strstr |
12.11 | String Library Functions : sprintf() | sscanf() |
12.12 | Reading String with Space using scanf() |
12.13 | Difference between char *a and char a[] in C Programming |
Storage Classes in C
Tutorial will explain different Storage Classes in C -
No | Topic - Storage Classes in C |
---|---|
11.1 | Introduction to Storage Class in C |
11.2 | What does Storage Class of Variable Determines ? |
11.3 | Storage Class Scope |
11.4 | Block Scope : Advantages | Disadvantage |
11.5 | File Scope : Advantages | Disadvantage |
11.6 | Storage Class : Auto | Extern | Static | Register |
Pointer in C
This tutorial will provide you brief knowledge regarding pointer in C.
Function in C
This chapter will cover Function in C Programming -
No | Topic - Function in C Programming |
---|---|
9.1 | What is Function ? |
9.2 | What is main Function ? |
9.3 | Why Function is Used ? |
9.4 | How Function Works ? |
9.5 | Types of Function 1 : No Argument and No Return Type |
9.6 | Types of Function 2 : Argument and No Return Type |
9.7 | Types of Function 3 : Argument and Return Type |
9.8 | Rules for Writing Function ? |
9.9 | Function Parameter : Formal | Actual |
9.10 | Function Definition | Calling | Prototype Declaration |
9.11 | Calling Function : Types | Ways Part 1 | Part 2 |
9.12 | Parameter Passing Sequence in Function |
9.13 | Introduction to Recursive Function |
9.14 | Pass by Value and Pass by Address |
Array in C
This Chapter will cover Array in C Programming -
No | Topic |
---|---|
8.1 | Introduction : What is an array ? |
8.2 | Limitations of Array |
8.3 | Application of Array |
8.4 | Types of an Array : 1-D | Multi Dimensional |
8.5 | 1-D Array Declaration |
8.6 | Initializing 2-D array |
8.7 | Memory Representation (Multi-Demensional array) |
8.8 | Accessing array Elements |
8.9 | Passing Array to Function : Entire Array | Element by Element |
8.10 | Accessing Array Randomly : How a[i] works ? |
8.11 | Initializing Array : Run-Time | Compile-Time |
8.12 | Common Errors : Array |
Loop Control Statements in C
Chapter covers Loop Control Statements in C Programming Language -
No | Topic |
---|---|
7.1 | For Loop : Introduction | Flowchart |
7.2 | Different Ways of Writing For Loop |
7.3 | Nesting of For Loop |
7.4 | While Loop Introduction |
7.5 | Infinite While Loop |
7.6 | Do-While Loop |
7.7 | Differenciation : For Loop Vs While Loop |
7.8 | Differenciation : For Loop Vs Do-While Loop |
7.9 | Differenciation : While Loop Vs Do-While Loop |
7.10 | Unconditional Jump : continue | break | exit |
Decision Making in C
This chapter is dedicated to Decision Making in C -
No | Topic |
---|---|
6.1 | Conitional Statements - If Statement | If-Else |
6.2 | Nesting of Statements - Nested If-Else | Else-If Ladder |
6.3 | Multiple Condition inside If |
6.4 | Multiple Statements in If Block |
6.4 | Introduction to Switch Statement |
6.5 | Rules of Using Switch Case |
6.6 | Invalid Ways of Using Switch Case |
6.7 | Conditional Operation : ?: Operator | Rules |
6.8 | Jumping Statements : Goto Statement | Break |
Data Types in C
Operators in C
No | Topic |
---|---|
4.1 | Assignment Operator |
4.2 | Arithmetic Operator |
4.3 | Increment Operator : Pre-Increment / Post-Increment |
4.4 | Decrement Operator : Pre-Decrement / Post-Decrement |
4.5 | Relational Operator |
4.6 | Logical Operator |
4.7 | Bitwise Operator |
4.8 | Conditional Operator |
4.9 | & and * Pointer Operators |
4.10 | Comma Operator |
4.11 | Dot Operator |
4.12 | Arrow Operator |
4.13 | [ ] and ( ) Operators |
4.14 | Operator Precedence Table and Associativity |
Variables in C
No | Topic |
---|---|
3.1 | Basic Building Blocks in C |
3.2 | Variable in C Programming : |
What is Variable ? | |
Variable Type : Local Variable | |
Variable Type : Global Variable | |
Fundamental Attributes of Variable | |
Rules for Declaring Variable | |
L-Value of Variable | |
R-Value of Variable | |
3.3 | Constant in C |
3.4 | Type of Constants : Character | Integer | String |
3.5 | Backslash Character : List | Properties |
3.6 | C Programming Character Set |
3.7 | Keywords in C |
3.8 | Special Characters in C : Backslash Characters |
3.9 | Backslash Characters with Examples |
3.10 | White Space Characters in C |
3.11 | Expression in C |
Overview of C
No | Topic |
---|---|
2.1 | Features of C Language |
2.2 | Application of C Programming |
2.3 | Compiler |
2.4 | Compiler Phases : Phase 1 | 2 | 3 | 4 | 5 | 6 |
2.5 | Interpreter |
2.6 | Compiler Vs Interpreter |
2.7 | Execution of C Program |
2.8 | Type of Languages : |
Low Level Language | |
Middle Level Language | |
High Level Language | |
2.9 | What is Comment in C ? |
2.10 | Types of Comment : Single Line | Multi Line |
2.11 | Difference Between Single and Multi Line Comment |
C Programming History
No | Topic |
---|---|
1.1 | History of C Programming |
1.2 | C Programming History Chart |
1.3 | Father of C Programming |
C Programming History : Multiple Choice Questions
No | MCQ Topic | Questions |
---|---|---|
2.1 | History of C Programming MCQ | 10 |
2.2 | About Dennis Ritchie MCQ | 10 |
Question 4 : How to add two numbers using function pointer ?
How to add two numbers using function pointer ?
#include<stdio.h> int sum (int n1,int n2); int main() { int num1 = 10; int num2 = 20; int result; int *(*ptr)(int,int); ptr = ∑ result = (*ptr)(num1,num2); printf("Addition : %d",result); return(0); } int sum (int n1,int n2) { return(n1 + n2); }
Explanation :
- Write whole program using normal function call i.e sum(num1,num2);
- After you write whole code, just erase line in which we have called function and replace that line with following line -
Step 1 : Declaring Pointer Variable
int *(*ptr)(int,int);
means -
Declare pointer variable which is capable of storing address of function which have integer as return type and which takes 2 arguments.
Step 2 : Initializing function Pointer
ptr = ∑
- Store address of function in Function Pointer
Step 3 : Calling Function
result = (*ptr)(num1,num2);
It will call function sum(num1,num2);
above statement will be elaborated as -
result = (*ptr)(num1,num2); result = (*&sum)(num1,num2); result = (*&sum)(num1,num2); result = (sum)(num1,num2); result = sum(num1,num2);
R-Value in Expression : C Programming
In the previous chapter we have learnt about the Lvalue of an expression in this chapter we are going to learn R-value of an expression.
What is R-Value ?
- R Value stands for Right value of the expression.
- In any Assignment statement R-Value must be anything which is capable of returning Constant Expression or Constant Value.
- R Value Can be anything of following -
Examples of R-Value | |
---|---|
Variable | Constant |
Function | Macro |
Enum Constant | Any other data type |
Diagram Showing Lvalue :
Example of RValue :
#include<stdio.h> int main() { int num; num = 5; return(0); }
In the above example, Constant Value 5 is assigned to the variable will be considered as right Value of the variable.
Important Tips of Using RValue :
Tip 1 : R Value may be Constant or Constant expression
num = 20; //Constant RValue num = 20 + 20; //Constant Expression as RValue
- In the example, we have assigned constant value to the variable.
- Constant value “20” is considered as RValue.
- In the next line we have assigned constant expression to the variable. “20 + 20” will be evaluated first and then result of expression will be assigned to an Variable.
Tip 2 : R Value may be MACRO
#define MAX 20 main() { int num = MAX; }
If we have defined a MACRO then we can use MACRO as right value. In the above example we have assigned the 20 to the variable “num”.
In case if we defined the MACRO value of different data type then it may results into compile error.
Tip 3 : R Value may be Variable
#define MAX 20 main() { int flag = 0; int num = flag; }
For more information , Visit MSDN library.
L-Value in Expression : L-value require Error [Solved]
What is LValue ?
- Lvalue stands for left value and Expressions that refer to memory locations are called “l-value” expressions.
- In any Assignment statement L-Value must be a container ( i.e. which have ability to hold the data)
- Variable is the only container in C thus L Value must be any Variable.
- L Value Cannot be Constant,Function or any of the available data type in C
Diagram Showing Lvalue :
Example of LValue :
#include<stdio.h> int main() { int num; num = 5; return(0); }
In the above expression, Constant value 5 is being assigned to a variable ‘num’. Variable ‘num’ is called as storage region’s , ‘num’ can considered as LValue of an expression.
Important Concepts about : LValue of an Expression
Tip 1 : Lvalue cannot be a Constant
int main() { int num; 5 = num; //Error return(0); }
Tip 2 : Lvalue cannot be a Constant Variable
int main() { const num; num = 20; //Error return(0); }
Tip 3 : Lvalue cannot be a MACRO
#define MAX 20 int main() { MAX = 20; //Error return(0); }
Tip 4 : Lvalue cannot be a Enum Constant
enum {JAN,FEB,MARCH}; int main() { JAN = 20; //Error return(0); }
Tip 5 : Lvalue cannot be a Data Type
#define<stdio.h> #define max 125 struct book{ char *name; int pages; }; void main() { book = {"C Programming",100}; }
How to solve this error : L-Value Require error ?
Causes of Error :
- Whenever we are trying to assign value to constant value
- Whenever we are trying to increment or decrement Constant Expression
- Inside if statement , if we try to write comparison operator as “= =” instead of ”==”, then we will get this error.
Solution :
Solution to this problem is very simple -
Question 3: What is the difference between constant to pointer and pointer to constant?
What is the difference between constant to pointer and pointer to constant?
No | Pointer to Constant | Constant Pointers |
---|---|---|
1 | *ptr = 20 Statement is Invalid in Pointer to Constant i.e Assigning Value is Illegal | *ptr = 20 is Absolutely Valid in Constant Pointers i.e Assigning Value is Perfectly legal |
2 | ptr ++ Statement is Valid in Pointer to Constant | ptr ++ Statement is Invalid in Constant Pointers |
3 | Pointer Can be Incremented and Decremented | Pointer Cannot be Incremented and Decremented |
4 | Pointer is Pointing to Constant Data Object | Constant Pointer is Pointing to Data Objects |
5 | Declaration : const int *ptr ; | Declaration : int * const ptr ; |