0% found this document useful (0 votes)
14 views

1-Introduction to Structured Programming - C language History and Introduction - Datatypes-Basic IO statements - Variables - Keywords - Expression evaluation using operator precedence-17-12-2024

The document outlines the course objectives, outcomes, and assessment methods for BCSE102L - Structured and Object-Oriented Programming at VIT, Vellore. It covers fundamental programming concepts, including structured programming, object-oriented programming, and practical applications using languages like C and C++. The course includes various modules, assessments, and guidelines for laboratory work and submissions.

Uploaded by

golaniaman07
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

1-Introduction to Structured Programming - C language History and Introduction - Datatypes-Basic IO statements - Variables - Keywords - Expression evaluation using operator precedence-17-12-2024

The document outlines the course objectives, outcomes, and assessment methods for BCSE102L - Structured and Object-Oriented Programming at VIT, Vellore. It covers fundamental programming concepts, including structured programming, object-oriented programming, and practical applications using languages like C and C++. The course includes various modules, assessments, and guidelines for laboratory work and submissions.

Uploaded by

golaniaman07
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

BCSE102L- Structured and object-

oriented programming

Dr. P.SURESH
Associate Professor
School of Computer Science &
Engineering(SCOPE)
VIT,Vellore.
BCSE102L- Structured and object-oriented
programming – Course Objective

1. To impart the basic constructs in structured


programming and object oriented paradigms.

2. To inculcate the insights and benefits in accessing


memory locations by implementing the real world
problems.

3. To help solving the real world problems through


appropriate programming paradigms.
BCSE102L- Structured and object-
oriented programming – Course outcome
1. Understand different programming language
constructs and decision making statements,
manipulate data as a group.
2. Recognize the application of modular programming
approach, create user defined data types and
idealize the role of pointers.
3. Comprehend various elements of object oriented
programming paradigm, propose solutions through
inheritance and polymorphism, identify the
appropriate data structure for the given problem
and devise solution using generic programming
techniques.
BCSE102L- Structured and object-oriented programming
BCSE102L- Structured and object-
oriented programming – Text Books and
Reference Books
BCSE102L- Structured and object-
oriented programming
Assessment Configuration(THEORY)
Assessment Syllabus Date Marks
method Coverage
QUIZ-1 Unit 1,2,3 Before CAT1 10
CAT-1 As decided in As Scheduled by 15(50)
Course Committee Dean Academics
Meeting
QUIZ-2 Unit 4,5,6 Before CAT 2 10
CAT-2 As decided in As Scheduled by 15(50)
Course Committee Dean Academics
Meeting
Digital All Modules Before FAT 10
Assignment
FAT All Modules As Scheduled by 40(100)
Dean Academics
BCSE102P- Structured and object-
oriented programming Laboratory
BCSE102L- Structured and object-
oriented programming

Assessment Configuration(LAB)
Assessment Syllabus Marks Pattern
Component Coverage

Problem set-I Module 1 & 2 10 Take home assignment


Problem set-II Module 3 & 4 10 Take home assignment
Problem set-III Module 5 & 6 10 Take home assignment
Problem set-IV Module 7 & 8 10 Take home assignment
Lab CAT All the 8 Modules 20 To be conducted with one
Problem each in C and
C++
FAT All the 8 Modules 40 To be conducted for 50
marks with one Problem
each in C and C++
Lab Component Assessment

 Assessment questions will be uploaded in VTOP/


intimated in class.
 An assessment will include questions from
multiple lab sessions
 Programming type (C,C++)
 Attach the screenshot of the output after the
code.
 Check the output for multiple and diverse test
cases and include all screenshots.
 Only a single PDF document is allowed per
assessment.
 Submission can be done only through VTOP
General Guidelines

 All DAs must be submitted through VTOP only.


 No other mode (such as email) is accepted
 Submit assignments well in advance to avoid
probable network issues/VTOP login errors at
the last moment.

Queries????

All the Best


BCSE102L- Structured and Object-
Oriented Programming - MODULES
 Module-1: C Program Fundamentals

 Module-2:Arrays and Functions

 Module-3: Pointers

 Module-4: Structure and Union

 Module-5: Overview of object Oriented


Programming

 Module-6: Inheritance

 Module-7: Polymorphism

 Module-8: Generic Programming


BCSE102L- Structured and Object-
Oriented Programming
 Module-1:C Program Fundamentals -
Introduction
◦ Variables

◦ Reserved Words

◦ Data types

◦ Operators- Operator Precedence

◦ Expressions

◦ Type Conversions

◦ I/O Statements
.
BCSE102L- Structured and Object-
Oriented Programming
 Module-1: C Program Fundamentals –
Branching and Looping
◦ if, if-else, nested if, else-if ladder

◦ Switch Statement

◦ Goto Statement

◦ Looping

 For

 While and do while

◦ Break Statement

◦ Continue Statement
.
BCSE102L- Structured and Object-
Oriented Programming
 What is Program?
◦ Set of instructions that instruct
the CPU to perform a defined task.
◦ We can write computer programs using
various programming languages
◦ Programming paradigm is a way of
categorizing a programming language
depending on its features
 Structured Programming
 Object-Oriented Programming
What is Structured Programming??
Structured/ Modular Programming
• Developing a program using a set of modules or
functions

• Subset of Procedural Programming, user-friendly and


easy to understand.
• Functions have statements embraced inside curly
braces.
• Each Functions represents a functionality and performs
a specific task.
• Main method communicates with functions by calling
those functions in the main program
What is Structured Programming??
Structured/ Modular Programming
• Easier for the programmer to test and debug the code.
• Top down Approach
• Difficult to modify.
• Data is not secure in structured programming.
• Difficult to reuse code in structured programming
Why did We Learn Python?

• Easy to learn
• Language with simple rules
• Good for beginners
• Code is readable
• Less development time
• Great support for building web apps
• Dynamic language and no type
checking
Limitations in Python
Python is not a good choice for:
• Memory intensive and computation intensive tasks.
• Embedded Systems where processor has limited
capacity.
• For graphic intensive 3D game that takes up a lot of
CPU.
• Applications that demand concurrency and parallelism
• Developing mobile apps
• Interpreted language and is slow compared to C/C++ or
Java
Transition from Python to
C/C++
• Will not be so hard
• There are quite a few syntax
differences between the two
languages
• Only way to learn a new programming
language is by writing programs in it
– Dennis Ritchie
Types of Programming Language
 Low level Programming Language
◦ Machine Language – Machine code- only
electronic machines such computers, mobiles
etc.. understands this – In 0’s and 1’s format.
◦ Assembly language – Directly connected
with Computer Architecture.
 High level Programming Language
◦ C https://www.mentofacturing.com/vincent/impleme
◦ C++ ntations.html

◦ JAVA C is a language which is directly


communicating/working with systems at very low
◦ Python level and interact with computer hardware's.
Simple Problems at a Glance

ABC company Ltd. is interested to


computerize the pay calculation of their
employee in the form of Basic Pay,
Dearness Allowance (DA) and House
Rent Allowance (HRA). DA and HRA are
calculated as certain % of Basic pay(For
example, DA is 80% of Basic Pay, and HRA
is 30% of Basic pay). They have the
deduction in the salary as PF which is 12%
of Basic pay. Propose a computerized
solution for the above said problem.
Simple Problems at a Glance
Input : Basic Pay // Getting from the user
Process : Calculate Salary // Calculated by machine

= Basic Pay + ( Basic Pay * 0.8) + ( Basic Pay * 0.3 ) - ( Basic Pay * 0.12)
----------------allowances ---------------- --- deductions----
Output : Salary
Simple Problems at a Glance

Little Bob loves chocolate, and he goes to a


store with “Rs. N” in his pocket. The price
of each chocolate is “Rs. C”. The store
offers a discount: for every “M” wrappers
he gives to the store, he gets one chocolate
for free. This offer is available only once.
How many chocolates does Bob get
to eat?
Simple Problems at a Glance
Input :
◦ Amount in hand, N
◦ Price of one chocolate, C
◦ Number of wrappers for a free chocolate, M
Process :
◦ Number of Chocolates P = Quotient of N / C
◦ Free chocolate F = Quotient of P/M

Output : Total number of Chocolates got by Bob


C Programming- Fundamentals

 What is C?
◦ C is a programming language developed at AT
& T’s Bell Laboratories of USA in 1972.
◦ It was designed and written by Dennis Ritchie.
◦ Structured and machine independent
language.
◦ Unix is one of the most popular network
operating system and it was coded entirely in
C
◦ Reliable and Friendly language
◦ What’s next?? C->C++->Java
History of C Language
Language Year Developed By
Algo 1960 International Group
BCPL 1966 Martin Richard
Traditional C 1969 Ken Thompson
K&RC 1972 Dennis Ritchie
ANSI C 1978 Kernighan & Dennis Ritchie
ANSI/ISO C 1989 ANSI Committee
C90 1990 ISO Committee
C99 1999 ISO Committee
C11 2011 Standardization Committee
C18 2018 Standardization Committee
C Programming- Fundamentals
 Features of C
◦ General-purpose Structured language
◦ Free format and case-sensitive language
◦ System Programming language
◦ Fast running and efficient language
◦ Machine independent and hence it is portable
◦ Commands can be inserted anywhere in the program
◦ Memory address are directly accessed by using
pointers
◦ Supports modularity
◦ Permits recursion
◦ More built-in functions
Getting Started with C
 Communicating with a computer involves speaking the
language the computer understands.
 What is the learning method of English??

 Steps in learning C
World in “C”
 OS – Windows / UNIX / LINUX
 Device Drivers Programs
 Mobile Devices
 Microprocessor in washing machine, digital
camera, microwave oven. Embedded C
 3D Computer Games - still written in C

C is always best when it comes to


performance(in terms of speed of execution)

C is the building block of all the programming


languages
What’s Next?? ………Implementation
 IDE
 Single platform where you get numerous
features required such as text editor, syntax
highlighter, customizable interfaces, compiler,
code auto-save,debugger, build automation, and
deployment.
 Why IDE?
◦ Writing programs easy, efficient, and effective.
◦ It saves lot of time.
◦ Freedom to choose the programming language
of your interest.
 Eclipse, Visual stdio, Netbeans, Clion, Code Blocks,
Codelite, Qtcreater etc….
How To Install and Getting Started
 CodeBlocks is an open-source, cross-platform
(Windows, Linux, MacOS), and free C/C++ IDE.
Website : www.codeblocks.org/downloads
Step 1: Download
 Go to http://www.codeblocks.org/downloads. Click
"Download the binary release".

 Select your operating platform (e.g., Windows


XP/Vista/7/8.x/10 or Linux 32 and 64-bit or Mac OS X).

 Download the installer with GCC Compiler(codeblocks-


20.03mingw-setup.exe) (which includes MinGW's GNU
GCC compiler and GNU GDB debugger).
Step 1: Download
Step 2: Double-click to run the downloaded
installer and click the “Next >” button.
Step 3: Now click “I Agree” to accept the
license agreement.
Step 4: The next step, don’t do anything, just
click the “Next >” button to install
packages.
Step 5: On the next window, then change the
installation directory if you want (default directory
recommended). Click the “Install” button.
Step 6: After the installation is completed
click the “Next >” button..
Step 7: To complete the installation process
click the “Finish” button.
RUNNING AND CONFIGURATION
• Go to Start Menu > All Apps > CodeBlocks > CodeBlocks.
• In the window “Compiler auto-detection”, just click the “Ok”
button.
RUNNING AND CONFIGURATION
• Make a choice for the file association and click on the
“OK” button
RUNNING AND CONFIGURATION
• Final coding Window
RUNNING AND CONFIGURATION
• Verify the Compiler's and Debugger's Path:
• Goto "Settings" menu ⇒ "Compiler..." ⇒ In "Selected
Compiler", choose "GNU GCC Compiler"
• Select tab "Toolchain Executables" ⇒ Check the
"Compiler's Installation Directory". It shall be set to
the "MinGW" sub-directory of the CodeBlocks
installation directory, for example, suppose that
CodeBlocks is installed in "c:\Program
Files\codeblocks", set it to "c:\Program
Files\codeblocks\MinGW".
RUNNING AND CONFIGURATION
• Verify the Compiler's and Debugger's Path:
RUNNING AND CONFIGURATION
• Checking of Debugger's Path:

Goto "Settings" menu ⇒ "Debugger..." ⇒ Expand


"GDB/CDB debugger" ⇒ Select "Default" ⇒ In
"Executable path", provide the full-path name of "gdb.exe",
For example, "c:\ProgramFiles\codeblocks\MinGW\bin\gdb.exe".
RUNNING AND CONFIGURATION
• Checking of Debugger's Path:
Writing C/C++ Program in Code blocks

• For Simple Programming Exercise

• File ⇒ New ⇒ Empty File.


• Enter the Code
• Save the file as “test1.c" in your own directory (e.g.,
"D:\IYAPPANDATA\VIT\NOV2022 - APRIL 2023\C&C++").
• Build (Compile and Link): Select "Build" menu ⇒ Build
(Ctrl-F9).
• Run: Select "Build" menu ⇒ Run (Ctrl-F10).
• Build and Run=> F9
Writing C/C++ Program in Code blocks

• Writing Programs(Under Project)


• A project contains related files such as source codes,
header files, and relevant resources. Also, under
CodeBlocks, you can only debug your program under
a project - single-file program (in previous section)
debugging is not supported.
• File ⇒ New ⇒ Project... ⇒ Console Application ⇒
Go. "Console Application" wizard appears => Next
Writing C/C++ Program in Code blocks

• Writing Programs(Under Project)


Writing C/C++ Program in Code blocks

• Writing Programs(Under Project)


Writing C/C++ Program in Code blocks
• Writing Programs(Under Project)

In "Project Title", enter “ProjectName”. In "Folder to create project in", set to


your working directory, e.g., "D:\IYAPPANDATA\VIT\NOV2022 - APRIL
2023\C&C++"". Accept the default for the rest ⇒ Next.
Writing C/C++ Program in Code blocks
• Writing Programs(Under Project)

• Under the "Management" pane ⇒ Choose "Projects"


tab ⇒ Expand the project node "ProjectName" ⇒
Expand "Source" node ⇒ Double-click "main.c", which is
a template program to say "Hello, world!".

• To build the program, select "Build" menu ⇒ Build.


• To run the program, select "Build" menu ⇒ Run.
.
Writing C/C++ Program in Code blocks
Create more source file or header file under the
project

• File ⇒ New File... ⇒ Select C/C++ source or C/C++


header =>C ⇒ Next.
• In "Filename with full path" ⇒ Click the "Navigate" (...)
button to navigate to the project directory and enter
the new file name. Check both the "Debug" and
"Release" boxes (or "All") ⇒ Finish
.
Sample Problems to Try

• Find the average runs scored by a batsman


in 4 matches.
• Area of a circle
• Compute Simple interest, compound
interest.
• Convert Fahrenheit to centigrade and
vice-versa.
.
.

Thank you

You might also like