31

C programming tokens & error types

Embed Size (px)

DESCRIPTION

C programming tokens & error types

Citation preview

Page 1: C  programming tokens & error types
Page 2: C  programming tokens & error types

NOTES

Page 3: C  programming tokens & error types

NOTES

Page 4: C  programming tokens & error types

NOTES

Page 5: C  programming tokens & error types

NOTES

Page 6: C  programming tokens & error types

NOTES

Page 7: C  programming tokens & error types

NOTES

Page 8: C  programming tokens & error types

NOTES

Page 9: C  programming tokens & error types
Page 10: C  programming tokens & error types

NOTES

Page 11: C  programming tokens & error types

NOTES

Page 12: C  programming tokens & error types

NOTES

Page 13: C  programming tokens & error types

NOTES

Page 14: C  programming tokens & error types

NOTES

Page 15: C  programming tokens & error types

NOTES

Page 16: C  programming tokens & error types

Input from User –

#include<stdio.h>#include<conio.h>void main(){

int a, b,c;clrscr();printf(“Enter 1st Number\n”);scanf(“%d”,&a);printf(“Enter 2nd Number\n”);scanf(“%d”, &b);printf(“Value of 1st No = %d\n”,a);printf(“value of 2nd No = %d\n”,b);c=a+b;printf(“Sum of two no = %d\n”, c);getch();

}

Page 17: C  programming tokens & error types

NOTES

Page 18: C  programming tokens & error types

NOTES

False

Page 19: C  programming tokens & error types

Increment & Decrement Operator

Increment & Decrement Operator is two typei. Pre Increment / Decrement Operator -

Increase/ Decrease the variable values then print e.g. ++a / --aii. Post Increment / Decrement Operator –

Print the variable values then Increase / Decrease e.g. a++/a--#include<stdio.h>#include<conio.h>void main(){

int a=5;clrscr();printf(“Value of a in 1st Step = %d\n”,a);printf(“Value of a in 2nd Step = %d\n”,++a);printf(“Value of a in 3rd Step = %d\n”,a);printf(“Value of a in 4th Step = %d\n”,a++);printf(“value of a in 5th Step = %d\n”,a);getch();

}

Page 20: C  programming tokens & error types

EXTRA

Page 21: C  programming tokens & error types

NOTES

Page 22: C  programming tokens & error types

NOTES

Page 23: C  programming tokens & error types

NOTES

Page 24: C  programming tokens & error types

NOTES

Page 25: C  programming tokens & error types

NOTES

Page 26: C  programming tokens & error types

NOTES

Page 27: C  programming tokens & error types

Syntax Error

It occurs when grammatical error has found.

EX:-int a

Here semicolon sign missing so it is related through ‘C’ program grammar So, Syntax error occur.

EXTRA

Page 28: C  programming tokens & error types

Symantic Error

This type of error occur when statement are not meaningful.

EX:-a+b = c;

It is wrong assignment here statement are not meaningful here should be c = a+b.

EXTRA

Page 29: C  programming tokens & error types

Type Error

This type of error occur when datatypemismatch.

Ex:- int a = 3.5;

char c = 4;Here a is integer variable so it can

not hold floating value and in second line c is the character variable and it can not integer value.

EXTRA

Page 30: C  programming tokens & error types

Logical error

This type of error occur when your statement is logically incorrect.

Ex:-int i = 1;

while(i>=10) /*value of i never be greater than 10*/

{printf(“%d\n”,i);

}

EXTRA

Page 31: C  programming tokens & error types

Run time Error

This type of error occur during run time or execution time.

Ex:- You are trying to open a file which

does not exist it will occur run time error.Its another example is , you are making

Infinite loop.(endless loop).

EXTRA