0% found this document useful (0 votes)
3 views29 pages

Introduction To Algorithm & Programming-20250902100801

This document serves as an introduction to the C programming language for first-year students at Binus University, covering its history, structure, and practical applications. It outlines the flow of developing a C application, including design, coding, compiling, and running the program, while also providing resources for learning and coding in C. Additionally, it explains key concepts such as data types, variables, input/output operations, and arithmetic operators, along with exercises to reinforce learning.

Uploaded by

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

Introduction To Algorithm & Programming-20250902100801

This document serves as an introduction to the C programming language for first-year students at Binus University, covering its history, structure, and practical applications. It outlines the flow of developing a C application, including design, coding, compiling, and running the program, while also providing resources for learning and coding in C. Additionally, it explains key concepts such as data types, variables, input/output operations, and arithmetic operators, along with exercises to reinforce learning.

Uploaded by

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

Programming Introduction

(C Language Program)
First Year Program (FYP) Binusian 2029
Introduction
• Preparation to COMP6878051 - Algorithm and
Programming course at 1st semester.

• Textbook:
C : How to program :with an introduction
to C++
Paul Deitel & Harvey Deitel . 2016.
Pearson Education.
ISBN: 9780133976892
What is C?
• C was originally first implemented on the DEC PDP-11 computer in
1972.
• In 1978, Brian Kernighan and Dennis Ritchie produced the
first publicly available description of C, now known as the K&R
standard.
• The C has now become a widely used professional language for
various reasons.
Easy to learn
Structured language
It produces efficient programs.
It can handle low-level activities.
It can be compiled on a variety of computer platforms
Why Using C
• Flexibility
Close to low level machine language yet easy to understand (therefore great
performance)
• Portability
Used from micro computer to super computer
• A Well Known Programming Language
It is used in many forms of implementations such as O/S, scientific application,
business application, etc.
• Supported With a Large Number of Libraries
Flow of developing C application
(Simplified)
Flow of developing C application
(Simplified)
• Design step to your goal
• In here you analyze and design the flow and how to achieve the
desired outcome of our application. In here we are designing the
“Algorithm”.
• Code
• This step, you code the C program. In here we are doing the
“Programming” part
• Compile (Important)
• This step is when your code is parsed, error check/syntax check,
and transformed into executable file (in windows, there’ll be .exe
file).
• If any error is encountered, we go back to code step to do Error
Fix/ Bug Fix
• Run!
How to Start with C
• NOTE : Please use this platform to explore each of code in this session. You
need to try to run the code, and repair it if needed.

Online Compiler
- https://www.onlinegdb.com/onli
ne_c_compiler
OR - https://www.tutorialspoint.com/c
ompile_c_online.php
- https://www.w3schools.com/c/c_
compiler.php

DEV C++
How to Start with C
• If you are a bit adventurous, you may use this approach:
Compiler + Text Editor + Terminal
• So, you are able to build a C program even using this combination
(in windows):
C compiler (GCC, G++, Visual C++) + Notepad + Powershell.

• PS: Dev C++ actually a combination of Compiler, Text Editor, and


Built in Terminal, Which we called IDE (Integrated
Development Environment)
C Structure
• Directive #include generally written at the beginning of a
program, used to include external functions and libraries.
• Coding Style (depends to the programmer)

#include<stdio.h>
#include<stdio.h>
int main()
int main(){
{
printf (“Welcome to BINUS\n”);
printf (“Welcome to BINUS\n”);
return (0);
return (0);
}
}
Comments
• Lets say I want to give explanation for my block of code,
like what is my function is doing, or what is the use of
my variables, or why I code this segment.

• However if I just directly type such words or sentences in


our C code, I’ll encounter error. So how to do that in c?

• You can use “Comment”


Comments in C
• Used for readability of the program, and sometimes for
communications
• Not accounted as a command/statement by the compiler
• Using /* and */ for multiline, or // at the beginning of line for one
line comment.
• Example: /*--------------------------
My First Program
--------------------------*/
#include<stdio.h>
void main(){
printf (“Hello, BINUSIAN\n”);

}
// This program will simply print out a message
Identifier
• The naming mechanism for various element in a program such as: variable,
function, constant, etc.
• Started with a letter or underscore_
• It is case sensitive
• Maximum length is varying for every compiler
Example: Turbo 2.0 (DOS), max 32 characters
• Never use reserved word/keyword
(such as: for, while, if, main)
• Example:
name, x1, _total, cubic()
wrong: 1time, int
Data Types and Variables
• In our life is we have seen several things being
segmented into different types, right? We have
numbers, decimal numbers, texts, persons, races, etc.
• How do we represent these types and elements in C
programming language?
• In the C programming language, data types refer to
an extensive system used for declaring variables or
functions of different types.
• The type of a variable determines how much space it
occupies in storage and how the bit pattern stored is
interpreted.
Data Types and Variables
Variables
• Now we know that data types help categorize variables
or functions, and give a specific memory allocation in
RAM based on those types
• After that, we’ll learn “Variables”, an identifier to store
values into those blocks of memory so we can assign a
value, call the value, and do some operations
• A variable is a name/identifier given to a storage
area that our programs can manipulate.
• Each variable in C has a specific data type, which
determines the size and layout of the variable's
memory, also values that can be stored.
Variables
Examples
Example
#include<stdio.h>

int main(){
int a = 50;
float b = 10.53f;
double c = 40.7;
char d = 'A';

printf("%d | %.2f | %.3f | %c\


n",a,b,c,d);
getchar();
return 0;
}
Input Operation: scanf() function

scanf("%d %d %d",&y,&z,&w);

these’re format type. In here we these’re variables that we want to assign


have 3 integer value that’ll fetch value to. Don’t forget to use ‘&’. Which indicates
from user and store into our 3 int a memory pointing (RAM) process
variables
Output Operator: printf() function
• Printf() is used to show output into the screen
• Parameters are the same as scanf() which consists of format type and variables.

Printf(“Number of student here is: %d ”, students);

In here we don’t use ‘&variable’ because we aren’t assigning value to variable. We just
use variable
Arithmetic Operators
• An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. C language is rich in built-
in operators and provides the following types of operators:
Exercise
Create a program that input 2 number, and calculate the result :
• Input :
• Output :
Examples
• A program to convert rate of exchange from US Dollar to Rp.
• (input: Dolar)

Formula: Dolar = Rp / 15000

Simple Algorithm Solution :


Start
Read Rp
Dolar = Rp / 15000
Print Dolar
End
Exercise Length = 5

Create a program to calculate area


of rectangle with following formula:

area = length* width


Width = 3

Start
Print “Calculate Area of Rectangle”
Length = 5
Width = 3
Print “Area of Rectangle = ”
Area = Length * Width
Print Area
End
Exercise
Create a program that has input your name, and show the Output :
Welcome Binusian 2029
Berikut informasi penting untuk mengikuti kegiatan Academic Expericence
(AE):
• Untuk melihat jadwal pelaksanaan AE Sync (ViCon), silahkan akses
https://newbinusmaya.binus.ac.id/

You might also like