Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Introduction to Programming Languages, Schemes and Mind Maps of Mathematics

An introduction to various programming language concepts, including machine code, assembly code, high-level languages, compilers, software development, and the elements of the c programming language. It covers topics such as variables, data types (integers, floating-point numbers, characters, and character arrays), mathematical expressions, operators, type casting, operation precedence, and coding style. The document also includes several exercises and examples to reinforce the concepts. Overall, this document serves as a comprehensive introduction to the fundamental principles of programming languages and their implementation.

Typology: Schemes and Mind Maps

2020/2021

Uploaded on 06/08/2022

asd-asd-0xy
asd-asd-0xy 🇹🇷

2 documents

1 / 40

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Assoc. Prof. Dr. Tansu FİLİK
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download Introduction to Programming Languages and more Schemes and Mind Maps Mathematics in PDF only on Docsity!

Assoc. Prof. Dr. Tansu FİLİK

Bil 200 Week - 2

Previously on Bil 200

 Programming Languages (Machine Code, Assembly code, high-level languages)  Compiler (translator)  Software development (components of algorithm)  Top-Down software development  Elements of C-programming language

Variables and Values

int and float

 Integers (int)

 Floating point (real) numbers

- 1e

Bil200 – Computer Programming

Variables and Values

Characters (char)

 characters 'a' 'z' 'A' 'Z' '?' '@' '0' '9‘  Special characters are obtained using a \ sign before the indicator.  \n : skip to new line  \t : tab – skip 8 character spaces  ' : print out '  \ : print out backslash
etc..

Math Expressions

 They combine or change values of variables.

 Operators: + - * / %

 Functions: exp(), cos(), log()

 They return a value with a specific type.

Exercises

 Exercise 1

Calculate the area of a triangle whose base

length (b) and height (h) are given.

Read b and h values

Area ½ * b * h

Print Area

Exercises

 Exercise 3 For an average speed H, calculate the required amount of time for a travel between two locations that have distance U. Read H and U time U/H Print time

Exercises

 Exercise 4 Write a list of commands to read midterm, homework, and final grades of a student and calculate the total grade. The weight of final is twice of the midterm. Midterm and home work have the same weight. Read midterm, homework, and final total midterm + homework + 2*final average total / 4 Print average

Increment / decrement operators

 ++ is an increment operator.

i++;  means i = i + 1;

 -- is a decrement operator

j--;  means j = j - 1;  According to using “before” or “after” the variable, the operators may work slightly differently. i++; or ++i; do the same thing, but inherently, they work in a different manner with a different set of machine code instructions.

Increment / decrement operators

++k increment k by 1, and return the result to the expression that “uses” ++k.  k++ use the value of k in the expression that “uses” k++, and then increment the value of k by 1.  --k decrement k by 1, and return the result to the expression that “uses” --k.  k-- use the value of k in the expression that “uses” k--, and then decrement the value of k by 1.

Examples

 d - = 4 (d = d - 4)  e *= 5 (e = e * 5)  f /= 3 (f = f / 3)  g %= 9 (g = g % 9)  If the value of i is 5;  printf( "%d", ++i ); => Prints 6 on screen  printf( "%d", i++ ); => Prints 5 on screen In both cases, the value of i after execution is 6.

Exercise

*Determine the values of the variables after the following lines. Do it by hand first, then try at the computer. int i, j, k; i = 2; j = 3 + i++; k = 3 + ++i; i = ++k + j--; i /= k-- + ++j;

Type casting

Supported integer types

 C language has several integer types.  char 8 bit  short 16 bit  unsigned short 16 bit  int 32 bit  unsigned int 32 bit  long int 32 bit  unsigned long 32 bit

Type casting

Supported floating types

 C language has several floating point types.  float 32 bit  double 64 bit  long double 64 bit