0% found this document useful (0 votes)
8 views25 pages

Introduction To C

The document summarizes key concepts in the C programming language. It discusses C tokens such as identifiers, keywords, variables, strings, and constants. It also covers data types in C including primary, user-defined, derived, and empty types. Additionally, it mentions constants, escape sequences, operators, precedence and associativity of operators, and provides examples of code snippets and their output.

Uploaded by

Bhuvaneshwari B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views25 pages

Introduction To C

The document summarizes key concepts in the C programming language. It discusses C tokens such as identifiers, keywords, variables, strings, and constants. It also covers data types in C including primary, user-defined, derived, and empty types. Additionally, it mentions constants, escape sequences, operators, precedence and associativity of operators, and provides examples of code snippets and their output.

Uploaded by

Bhuvaneshwari B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

Summarization of C

Language: C

English Language C Language


26 Alphabets 32 Keywords

Alphabets Keywords (32), Operators(45), Separators(14)

Words Statements, Loops

Sentences Body of the Program

Paragraph Header Section , User defined Functions

Essay Program
C Tokens

Identifiers- Name of variables, Arrays, functions,


datatypes
Key words-should be in lower case
Variables- Identifiers used to store the data
values
Strings
Constants
Special Characters
Datatypes

Primary/Fundamental- char, int, float,double


User defined – typedef, enum
Derived – Arrays, pointer, structure, union
Empty - void

4
Constants

Integer – Decimal, Octal, Hexadecimal


Real- floating point
Char-single quotes
String- double quotes

5
Escape Sequences

\t Inserts a tab in the text at this point.

\b Inserts a backspace in the text at this point.

\n Inserts a newline in the text at this point.

\r Inserts a carriage return in the text at this point.

\f Inserts a form feed in the text at this point.

\’ Inserts a single quote character in the text at this point.

\” Inserts a double quote character in the text at this point.

\\ Inserts a backslash character in the text at this point.

6
Operators

Arithmetic(+,-,*,/,%)
Increment & Decrement(++,--)
Relational(<,>,<=,>=,==,!=)
Logical(&&,||,!)
Conditional/ Ternary(?:)
Bit-wise(&,|,~,<<,>>)
Assignment(=)
Special(,,*,&,sizeof(),.and->)

7
Precedence of Operators

(),[],.,->
Unary operator(!,~,+,-,++,--,&,*,sizeof)
Arithmetic(*,/,%,+,-)
Left and right shift
Relational
Bitwise
Logical
Conditional
Shorthand
Comma
8
Associativity of operators

Unary ,Shorthand Operator and Assignment –


Right to Left
Others – Left to Right

9
Samples

int a=10,20,30; value of a=10


int a=(10,20,30); value of a=30
int a=5; printf("%d"+1,a); d
int a=5; printf("%d%d"+2,a); 5
Printf(“%c”,’a’); a
Printf(“%c”,’Programme’); e
printf("%c ", “Programming"[3]); g

10
Samples

Coding Output
#include<stdio.h> 15
#include<Conio.h> 15
int main() 15 206592320
{
int a,b;
a=5,b=10;
printf("%d",a+b);
printf("\n%d",a+b,a);
printf("\n%d\t%d",a+b);
return 0;
}

11
Samples

Coding Output

int a,b;
float c,d;
a=10,b=4;
c=5.5,d=4;
printf("%d\t%d",a/b,a/c); 2 -536870912
printf("\n%d\t%d",c/a,c/d); -1610612736 0
printf("\n%d",a%b); 2

12
Samples

Coding Output

int a,b;
float c,d;
a=10,b=4;
c=5.5,d=4;
printf("%d\t%f",a/b,a/c); 2 1.818182
printf("\n%f\t%f",c/a,c/d); 0.550000 1.375000
printf("\n%d",a%b); 2

13
Samples

Coding Output

int a,b;
float c,d;
a=10,b=-4;
c=-5.5,d=4;
printf("%d\t%f",a/b,a/c); -2 -1.818182
printf("\n%f\t%f",c/a,c/d); -0.550000 -1.375000
printf("\n%d",a%b); 2
printf("\n%d",-a%b); -2

14
Shifting Operators

15
Logical Operator

a&&b If ‘a’ is not true(0), it won’t check the


value for b; result will be 0
a||bIf ‘a’ is true(1) it won’t check the value for
b; result will be 1
Eg:if a=0 and b=1
a&&++b0
a=0,b=1

16
Logical OR

int main()
{
int a=1,b=0; First:a=1,b=0,c=1
int c,d; Second:a=0,b=1,c=1,d=1
c=a||++b;
printf(“First:a=%d,b=%d,c

=%d",a,b,c);
d=--a||++b;
printf(“Second:a=%d,b=%
d,c=%d,d=%d",a,b,c,d);
}

17
Logical AND

int main() First: a=0,b=1,c=0,d=53


{
Second:a=1,b=2,c=0,d=1
int a=0,b=1;
int c,d;
c=a&&++b;
printf("First:a=%d,b=%d,c
=%d,d=%d\
n",a,b,c,d);
d=++a&&++b;
printf("Second:a=%d,b=%
d,c=%d,d=%d",a,b,c,d);
}
18
Increment/Decrement

{ {
int a=5,b; int a=5,b;
b=a++ + a++; b= ++a + a++;
printf("a=%d b=%d",a,b); printf("a=%d b=%d",a,b);
} }

Output: Output:

a=7 b=11 a=7 b=13

19
Increment/Decrement

{ {

int a=5,b; int a=5,b;

b= ++a + ++a; b= a++ + ++a;

printf("a=%d b=%d",a,b); printf("a=%d b=%d",a,b);

} }

Output: Output:

a=7 b=14 a=7 b=12

20
printf()

printf("""Hello"""); printf(""Hello"");

Output:Hello [Error] expected ')' before


'Hello'

21
printf()

• printf("%d",(printf("Hello")));
Hello5

• printf("%d",(printf("%d",(printf("Hello")))));
Hello51

22
printf()

• printf("%d",(scanf(“%d %d“,&a,&b)));
2
• printf("%d",(scanf(“%c %d“,&a,&b)));
2

23
24
25

You might also like