Structured programming

Similar documents
HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

You re most likely eager to get started programming in C. I shan t waste

USING CODEBLOCKS. Implementing Computational Models

Eclipse CDT Tutorial. Eclipse CDT Homepage: Tutorial written by: James D Aniello

An Introduction to Python (TEJ3M & TEJ4M)

CS201 RECITATION 1. Introduction to C++

Code::Blocks Student Manual

We first learn one useful option of gcc. Copy the following C source file to your

Chapter 2. Basics of Program Writing

IMPLEMENTING SCL PROGRAMS. Using Codeblocks

Installing Eclipse CDT and MinGW

Lab: Supplying Inputs to Programs

GUIDE Development tools for Windows(10) installation... 2

Embest IDE Pro for ARM 2005

Laboratory Assignment #3 Eclipse CDT

Computing and compilers

C++ Support Classes (Data and Variables)

CS354 gdb Tutorial Written by Chris Feilbach

Lab 1: Introduction to C Programming. (Creating a program using the Microsoft developer Studio, Compiling and Linking)

Code::Blocks Student Manual

Coding in C at Home. Part 2 Computational Physics. April 21, 2016

Debugging and Debugger. Terminology. GNU gcc and gdb. Debugging C programs in Unix and Windows Environments - Part One

JCreator. Starting JCreator

1.00 Lecture 2. What s an IDE?

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

Introduction to Computation and Problem Solving

Code Blocks Cannot Find Compiler Executable Windows 7

Running a C program Compilation Python and C Variables and types Data and addresses Functions Performance. John Edgar 2

Using Eclipse for C Programming

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3. Installing Notepad++

Reuse in a Unix Environment. Creating a Library. Libraries. Lecture 10: Unix Libraries

Using Eclipse. Computational Thinking and Engineering for pre-college! Using Eclipse. Must READ:

Computer Organization and Assembly Language. Lab Session 01

Reviewing gcc, make, gdb, and Linux Editors 1

A Tutorial on using Code::Blocks with Catalina 3.0.3

Module 3: Working with C/C++

Object-Oriented Principles and Practice / C++

Tutorial 2: Compiling and Running C++ Source Code

David Scuse Department of Computer Science University of Manitoba. Eclipse 3.1

Chapter 11 Introduction to Programming in C

EW The Source Browser might fail to start data collection properly in large projects until the Source Browser window is opened manually.

Code::Blocks on Windows Installation Guide using Msys

Release Notes. S32 Design Studio for ARM v1.1

Lecture 2. Xiaoguang Wang. January 16th, 2014 STAT 598W. (STAT 598W) Lecture 2 1 / 41

TNM093 Practical Data Visualization and Virtual Reality Laboratory Platform

EL2310 Scientific Programming

Getting started with UNIX/Linux for G51PRG and G51CSA

Chapter 11 Introduction to Programming in C

AMCAT Automata Coding Sample Questions And Answers

Jerry Cain Handout #5 CS 106AJ September 30, Using JSKarel

CS 220: Introduction to Parallel Computing. Arrays. Lecture 4

Building Allegro 5 Library using TDM-GCC and CMake

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3

AN5171 Application note

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

Laboratorio di Tecnologie dell'informazione

What s NetBeans? Like Eclipse:

CSE 351. GDB Introduction

Lab 9 Loops, Debugging

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

Introduction to C Programming. What is a C program?

Starting Embedded C Programming CM0506 Small Embedded Systems

Programming Studio #9 ECE 190

Handouts for Lecture 1

2 TUTORIAL. Overview. VisualDSP Getting Started Guide 2-1 for SHARC DSPs

C: Program Structure. Department of Computer Science College of Engineering Boise State University. September 11, /13

printf( Please enter another number: ); scanf( %d, &num2);

Why do some students find programming in C, so difficult? It involves thinking. We have been programmed by our respective school boards not to think.

Embedded Systems. 2. Software Development. Lothar Thiele. Computer Engineering and Networks Laboratory

MIS 0855 Data Science (Section 006) Fall 2017 In-Class Exercise (Day 18) Finding Bad Data in Excel

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2010

Chapter 11 Introduction to Programming in C

VikiLABS. July 8, 2017

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2005

Compilation and Execution Simplifying Fractions. Loops If Statements. Variables Operations Using Functions Errors

Development Environment & Linux Guide

Building and Running a Simple UML RT Model in RSARTE

Computer Hardware. Java Software Solutions Lewis & Loftus. Key Hardware Components 12/17/2013

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

Programming I Laboratory - lesson 01

esi-risc Development Suite Getting Started Guide

Chapter 11 Introduction to Programming in C

T Hands-on 2. User-mode debuggers OllyDbg

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

DEVELOPING OOSIML SIMULATION MODELS. Using Codeblocks

Pseudo Code and Flow Charts. Chapter 1 Lesson 2

Unit. Programming Fundamentals. School of Science and Technology INTRODUCTION

UNIT I. Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK-4. 1

Starting to Program in C++ (Basics & I/O)

EL2310 Scientific Programming

DS-5 ARM. Using Eclipse. Version Copyright ARM. All rights reserved. ARM DUI 0480L (ID100912)

Creating a new CDC policy using the Database Administration Console

Introduction to Supercomputing

Coding Tools. (Lectures on High-performance Computing for Economists VI) Jesús Fernández-Villaverde 1 and Pablo Guerrón 2 March 25, 2018

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Writing Code and Programming Microcontrollers


Intermediate Programming, Spring Misha Kazhdan

Lab 1: First Steps in C++ - Eclipse

Exercise Session 6 Computer Architecture and Systems Programming

Transcription:

Exercises 1 Version 1.0, 22 September, 2016

Table of Contents 1. Development environments (IDE)............................................. 1 1.1. Text editor.............................................................. 1 1.2. Compiler................................................................ 2 1.3. Debugger............................................................... 2 1.4. Integration with external libraries........................................ 2 1.5. Linker.................................................................. 3 1.6. Integrated Development Environment - IDE................................ 3 1.7. Installing Code::Blocks................................................. 3 1.8. Code::Blocks main window.............................................. 4 1.9. Elements of the main window............................................ 4 2. Programming in C with Code::Blocks.......................................... 5 2.1. Creating project......................................................... 5 2.2. Adding source file....................................................... 6 2.3. Programming........................................................... 7 3. Homework.................................................................. 9 3.1. Problem 1............................................................... 9 3.2. Problem 2............................................................... 9 4. Source code of the examples and problems................................... 10

1. Development environments (IDE) For writing programs, it is common to use development environments. The process of writing a program is the following: the source code is entered using the keyboard then follows the compiling of the source code the output is an executable i.e. a program written in the language of the computer Integrated development environment is mix of multiple programs, that are combined in order to simplify the development process: text editor compiler debugger external library integration linker 1.1. Text editor Program for inserting and editing the text of the source code Enables saving and loading already written source code files for editing Syntax highlighting Example of good text editors for writing source code are: Sublime Text Notepad2 Notepad++ Do not use Windows Notepad 1. Development environments (IDE) 1

1.2. Compiler Transforms (translates) the source code from the programming language (high level) to machine language Two types of code translators: Interpreters Compilers Interpreter is a translator of source code which translates each command separately, checks for errors and executes, and goes to the next command. Compiler is a translator which is processing the whole program, checks for errors, and creates the executable program. The resulted executable can be executed 1.3. Debugger Compilers and interpreters are detecting the (syntax) errors of the source code as a result from incorrect usage of the programming language Other type of errors are logical errors The program doesn t execute as intended Very difficult to discover Debugger is a program that helps discovering logical errors Enables execution step by step 1.4. Integration with external libraries Integration and usage of already created and correct modules, also called functions This type of organization has many advantages Reuse of standard functions 2 1.2. Compiler

Example libraries Standard input/output Mathematical operations 1.5. Linker Sometimes the program is to large to be written in one file different parts can be written by different programmers some parts from one program can be used in some other program Separately compiled parts must be united in on full executable with the help of the linker Another role is to link standard functions with the executable 1.6. Integrated Development Environment - IDE All these elements of the development environment are integrated in IDE. Code::Blocks is an example of IDE that can be used in this course. 1.7. Installing Code::Blocks How to find and install Code::Blocks? Code::Blocks is free software and can be find http://www.codeblocks.org/downloads In the central part of the page, there are three links: Download the binary release, Download the source code and Retrieve source code from SVN 1.5. Linker 3

The first link is recommended for most simple installation Download the binary release. Windows users should download the version codeblocks-16.01mingw-setup.exe. 1.8. Code::Blocks main window Figure 1. Main window 1.9. Elements of the main window Menu strip Menu strip is in to top left corner of the window, right bellow the title There can be found menus File, Edit, View, Search, Project, Build, Debug, wxsmith, Tools, Plugins, Settings, Help Toolstrip Toolstrip (buttons for starting most often used commands) are just bellow the menu strip 4 1.8. Code::Blocks main window

Workspace Text editor Info window for logs & others Window for management 2. Programming in C with Code::Blocks 2.1. Creating project Figure 2. New project Start Code::Blocks File New Project Empty Project Go Choose GNU GCC Compiler Select the next 2 options if you want to create debug and release configuration 2. Programming in C with Code::Blocks 5

Figure 3. Choose compiler 2.2. Adding source file Add source file in the project: File New File C/C++ Source Choose C as programming language Enter the file name with the full path, and don t forget to check Add file to active project 6 2.2. Adding source file

Figure 4. Adding source file Figure 5. Choosing configuration 2.3. Programming For each project following options can be checked Project Build Options.. Compiler Flags Project Build Options.. 2.3. Programming 7

Compiler Flags To build the project press Ctrl + F9 To execute the project press Ctrl + F10 Figure 6. Executing the program Figure 7. Build options 8 2.3. Programming

3. Homework In the next section are given some example problems that you should try to complete at home, so you can be ready for the next exercises. 3.1. Problem 1 Try to create new project with one.с file with the following source code: #include <stdio.h> int main() { printf("hi, how are you?\n"); return 0; } Execute the program What result do you get? If you made some errors during writing the code, try to find, correct them and execute again. Make some errors, intentionally. Execute again! What s happening now? 3.2. Problem 2 In the source code add the marked part: #include <stdio.h> int main() { printf("hi, how are you doing?\n"); // add this following line printf("so, yo're not in the mood for talking?\n"); return 0; } What is the result of the execution now? 3. Homework 9

4. Source code of the examples and problems https://github.com/finki-mk/sp/ Source code ZIP 10 4. Source code of the examples and problems