Emixa Mendix Meetup 11 April 2024 about Mendix Native development
introductory concepts
1. 2.0 INTRODUCTORY CONCEPT
CLO 1, CLO 2
1.Explain various programming problem using
design tools (C2)
2. Apply knowledge of basic concepts of
fundamental programming to solving a given
problem
2. 2.0 INTRODUCTORY CONCEPT
At the end of this chapter, student will be able to :
1. Define a variable and a constant
2. Identify the rules for naming variables and
constant,
3. Declare constants and variables
4. Build constant and variables
5. Explain keywords and operators in
programming
6. Use keywords and operators
3. 2.0 INTRODUCTORY CONCEPT
At the end of this chapter, student will be able
to :
7. Convert formula into C expression
4. 2.1 Constant And Variables(Identifier)
2.1.1 Variable And Constant
Variable
• Refer to the memory location
where the data is stored
• This value keeps changing during
the program execution
6. 2.1.1 Constant
• a location in the memory that stores
data that never changes during the
execution of the program
• constant can either be:
A numbers, like 15 or 10.5
A single character, like 'x' or '#„
A group of characters
(string), like “Beautiful
Malaysia”
7. 2.1.2 Rules For Naming Constants And
Variables
• Can be a combination of alphabets
and numbers but must start with an
alphabet
• Comprise maximum of 40 characters
• No commas or blank space is allowed
• No special characters can be used
except underscore (_)
8. 2.1.3 Declare Constants And Variables
• Constant and variable used in a program
must be declared in the beginning
• To specify the variable and constant data
type to the compiler
12. 2.0 INTRODUCTORY CONCEPT
2.1 Understand Constant And
Variables(Identifier)
2.1.5 Build Constants and variables in
Programmes
Total
Pie
Payment
13. 2.1.6 Identify and Explain Keywords in
C Programmes
Are reserved words for which the
meaning is already defined to the
compiler.
an identifier cannot have the same spelling
and case as a C keyword
14. Types
Keywords
Data types, modifiers and
storage class specifiers
void, int, char, float, double, signed,
unsigned, long, short, auto, const, extern,
static, volatile, register and typedef
User defined data types and
type related
struct,
Conditional
if, else, switch, case and default
Flow control
for, while, do, break, continue, goto and
return
union, enum and sizeof
15. 2.1.7 Use Keywords In Programmes
#include<stdio.h>
int main()
{
printf("Hello worldn");
return 0;
}
16. 2.1.7 Use Keywords In Programmes
#include<stdio.h>
main()
{
int a;
printf("Enter an integern");
scanf("%d", &a);
printf("Integer that you have
entered is %dn", a);
return 0;
17. 2.1.7 Use Keywords In Programmes
#include<stdio.h>
main()
{
char ch;
printf("Enter a charactern");
scanf("%c",&ch);
if ( ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' ||
ch=='O' || ch == 'u' || ch == 'U')
printf("%c is a vowel.n", ch);
else
printf("%c is not a vowel.n", ch);
return 0;
}
18. 2.0 INTRODUCTORY CONCEPT
2.2 Understand Data Types
Data Types
Data types are used to store various
types of data that is processed by
program. Data type attaches with
variable to determine the number of
bytes to be allocate to variable and
valid operations which can be
performed on that variable
19. 2.2.1 Basic Data Types in C
The C language provides a lot of basic types.
Most of them are
formed from one of
the four basic arithmetic type identifiers
in C (char, int, float and double), and
optional specifiers (signed, unsigned, short,
long). All available basic arithmetic
types are listed below:
20. Char
Short
Short int
Signed short
Signed short int
Int
Signed int
Long
long int
signed long
signed long int
long long
long long int
signed long long
signed long long int
float
double
22. Numeric
Keyword
char
int
short
short int
long
unsigned char
unsigned int
unsigned short
unsigned long
float
double
Variable Type
Character (or string)
integer
Short integer
Short integer
Long integer
Unsigned character
Unsigned integer
Unsigned short integer
Unsigned long integer
Single-precision
floating-point
(accurate to 7 digits)
Double-precision
floating-point
(accurate to 15 digits)
Range
-128 to 127
-32,768 to 32,767
-32,768 to 32,767
-32,768 to 32,767
2,147,483,648 to 2,147,483,647
0 to 255
0 to 65,535
0 to 65,535
0 to 4,294,967,295
+/-3.4E10^38 to +/-3.4E10^38
+/-1.7E10^308 to +/1.7E10^308
23. Characters
C stores character type internally as an
integer. Each character has 8 bits so we
can have 256 different characters values
(0- 255).Character set is used to map
between an integer value and a
character. The most common character
set is ASCII.
The char type store only one symbol of
data (letter, digit, space, tab and so on).
25. Logical
• Logical operators are used to combine two
simple statements into a compound statement.
• Using logical operators, you can simulate
Boolean algebra in C.
33. Statement
You will pass the exam only
when you get more than 50
in subject 1, subject 2 and
subject3.
To get a medal, you should
either be 1st or
2nd in
the race.
If your sex is not M, you are
girl
C Expression
if ((subject1>=50)&&(subject2>=50)&&(subject3>=50))
printf("PASS") ;
if ((position==1)|| (position==2))
printf("You got medal") ;
if (!(sex =='M') ){
printf("You are girl");
34. 2.3.5 Formula VS Expression
Formula
• Equation or a set of instructions that
solves a certain type of problems in a
prescribed manner.
• In a formula, the same set of inputs
always produces the same output(s).
35. e.g:
Net Pay = Gross Pay – Deductions
Circle Area = ¶R²
Voltage = Current + Resistant
R = ρ x L/A
36. Expression
• Expression in C++ are formed by
properly combining operators, variables
and constants.
• We have already seen some examples of
simple arithmetic and logical expression
• As algebra, C++ expression can be
complex.
• Parentheses can be used to force the
order of evaluation. An expression may
also contain spaces for readability.
38. 2.3.6 Convert Formula Into C
Formula
Expression
C Expression
Net Pay = Gross Pay – Deductions NetPay = GrossPay – Deductions
Area = ¶R²
Area = Pie x Radius * Radius
V = IR
V = Current x Resistant
R=L
L
_
A
Resistivity= Rho x(Length/Area)
39. 2.3.7 Operand And Operator
An operation is an action performed on
one or more values either to modify the
value held by one or both of the variables
or to produce a new value by combining
variables. Therefore, an operation is
performed using at least one symbol and
one value. The symbol used in an
operation is called an operator. A variable
or a value involved in an operation is called
an operand.