Slide 2 - Declare Variable and Assign Value (1)
Slide 2 - Declare Variable and Assign Value (1)
Fundamentals
1
2 Structure of C Program
• Preprocessor Commands
• Functions
• Variables
• Comments
3
Structure of C Program
Preprocessor Commands
Main Function
Comment
Library Function
End of Program
4 Preprocessor Commands
These commands tells the compiler to do preprocessing
before doing actual compilation.
Like #include <stdio.h> is a preprocessor command
which tells a C compiler to include stdio.h file before going
to actual compilation.
5 Functions
Functions are main building blocks of any C Program.
Every C Program will have one or more functions and there
is one mandatory function which is
called main() function.
Apon 1joty
joty-5
apon
apon123 this_is_a_long_name
_sojeb_1 VaReNdRa
15 Is it Valid Variable Name?
Expression Operator
Arithmetic Expression +, -, *, /, %
Logical Expression AND, OR, NOT
Relational ==, !=, <, >, <=, >=
24 Assign value to variable
To assign a value to a variable, put its name to the left of an equal sign (=).
Put the variable you want to give the variable to the right of the equal sign.
variable value
;
25
26 Constants
There are four basic types of constants in C.
1. integer constants,
Numeric type constant
2. floating-point constants,
3. character constants and
4. string constants.
Example
42 Errors!
A C program may have one or more of five types of errors:
Syntax errors (Compiler errors or Compile-time errors)
Linker Errors
Runtime Errors
Logic Errors
Semantic Errors
http://www.cprogramming.com/tutorial/common.html
(Some common programming Errors)
43 Syntax errors
Syntax errors represent grammar errors in the use of the
programming language. Common examples are:
Misspelled variable and function names
int num1; num = 10;
int i; i=i+2;
Type compatibility
int b = "javatpoint"; if (5 > 2.5)
Errors in expressions
int a, b, c;
a+b = c;
Array index out of bound