Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to programming Language C, Data Types, Variables, Constants. Basics of C –Every program consists of one or more functions and must have main.

Similar presentations


Presentation on theme: "Introduction to programming Language C, Data Types, Variables, Constants. Basics of C –Every program consists of one or more functions and must have main."— Presentation transcript:

1 Introduction to programming Language C, Data Types, Variables, Constants. Basics of C –Every program consists of one or more functions and must have main function –Functions consists of heading, arguments and compound statement –Every block begin with { and end with } –Every statement end with ; –// is used to insert single line comment

2 –/* … */ is used to insert multiple line C Fundamentals –Character set –Identifiers and keyword –Basic data types Int Character Float Double –Qualifiers

3 C Fundamentals (contd.) –Constants Integer constant –Decimal –Octal (start with 0) –Hexadecimal (start with 0x or 0X) Unsigned and Long Integer constant (UL) Floating point constant –Numerical accuracy (representation of 1.0) Character constant (enclosed by apostrophes) –ASCII, EBCDIC –Escape sequences (non-printing characters) String constant (enclosed in quotation marks)

4 C Fundamentals (contd.) Variables Declarations Expressions-+* Statements Symbolic constants #define name text

5 Operators and expressions Arithmetic operators (+, -, *, /, %) % requires integer operands and second operand must be nonzero Second operand of / must be nonzero Rules of division Type conversion ( (data type)) expression) Precedence and associativity

6 Operators and expressions (Contd.) Unary operators Relational operators (,>=) Equality Operators (==,!=) Logical operators or connectives(&&,||) –Act upon operands that are themselves logical expressions. The net effect is to combine the individual logical expressions into more complex conditions that are either true or false

7 Operators and expressions (Contd) –Any nonzero value, not just 1, is interpreted as true. –Logical and has higher precedence than logical or Logical negation operator(!, a unary) Assignment operators Conditional operators Library functions (abs, ceil, cos, floor, pow,

8 Operators and expressions (Contd) Rand, sqrt, tolower, toupper )

9 Data Input and Output Getchar(), putchar() Scanf(),scanf(“%[…]”),scanf(“%3d”), 3 is maximum field width Long decimal=%ld, long float or double=%lf Assignment suppression, “%*d” Scanf(“%c%1s%1s”,&c1,&c2,&c3) or scanf(“%c %c %c”)

10 Data Input and Output Scanf(“%d a %f”) Printf(), printf(“%3d”), 3 is minmum field width Printf(“%7.3f %.1f”) Printf(“%-7.0f %+7.0f%-+7.0f”)


Download ppt "Introduction to programming Language C, Data Types, Variables, Constants. Basics of C –Every program consists of one or more functions and must have main."

Similar presentations


Ads by Google