C programming tokens & error types

Preview:

DESCRIPTION

C programming tokens & error types

Citation preview

NOTES

NOTES

NOTES

NOTES

NOTES

NOTES

NOTES

NOTES

NOTES

NOTES

NOTES

NOTES

NOTES

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();

}

NOTES

NOTES

False

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();

}

EXTRA

NOTES

NOTES

NOTES

NOTES

NOTES

NOTES

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

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

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

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

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

Recommended