C-Language : Basic Concepts 2013, Fall Pusan National University Ki-Joune Li.

Slides:



Advertisements
Similar presentations
An Introduction to Programming with C++ Fifth Edition Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Advertisements

Senem Kumova Metin // FALL CS115 Introduction to Programming Inst. Senem Kumova Metin Textbook : A Book on C, A. Kelly.
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Computer Programming in C Chapter 년 가을학기 부산대학교 전자전기정보컴퓨터공학부.
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
B-1 Lecture 2: Problems, Algorithms, and Programs © 2000 UW CSE University of Washington Computer Programming I.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
CS211 Data Structures Sami Rollins Fall 2004.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
Course Introduction and Getting Started with C 1 USF - COP C for Engineers Summer 2008.
An Introduction to Programming with C++ Fifth Edition Chapter 1 An Introduction to Programming.
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich
6 Steps of the Programming Process
Chapter Introduction to Computers and Programming 1.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
CS130 Introduction to Programming with VB 6.0 Fall 2001.
Programming Design Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Introduction to .NET Framework
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 1 Quick Introduction The following.
Chapter 11 An Introduction to Visual Basic 2008 Why Windows and Why Visual Basic How You Develop a Visual Basic Application The Different Versions of Visual.
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Visual C++ Programming: Concepts and Projects
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Chapter 11 An Introduction to Visual Basic 2005 Why Windows and Why Visual Basic How You Develop a Visual Basic Application The Different Versions of Visual.
CC111 Lec7 : Visual Basic 1 Visual Basic(1) Lecture 7.
B.Ramamurthy11/9/20151 Computers and Programming Bina Ramamurthy 127 Bell Hall
CGS3460 Summer 2011 Programming Using C Andrei Todor.
1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Compilers and Interpreters. HARDWARE Machine LanguageAssembly Language High Level Language C++ Visual Basic JAVA Humans.
How to Program? -- Part 1 Part 1: Problem Solving –Analyze a problem –Decide what steps need to be taken to solve it. –Take into consideration any special.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Compilers and Interpreters
Skill Area 311 Part B. Lecture Overview Assembly Code Assembler Format of Assembly Code Advantages Assembly Code Disadvantages Assembly Code High-Level.
The Big Picture. My Story  Wrote great programs  Didn’t understand how they worked.
C Programming Lecture 3 : C Introduction 1 Lecture notes : courtesy of Woo Kyun and Chang Byung-Mo.
1 CSE1301 Computer Programming: Where are we now in the CSE1301 syllabus?
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 1: Introduction to Computers and Programming.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Computer science C programming language lecture 1.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Introduction to Computer Programming By: Mr. Baha Hanene Chapter 1.
Software Engineering Algorithms, Compilers, & Lifecycle.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Programming Language Basics. What is a Programming Language? “A computer, human-created language used to write instructions for a computer.” “An artificial.
Chapter 5: Preparing C Programs
CMPT 201 Computer Science II for Engineers
CMIT100 Chapter 14 - Programming.
Programming Languages
© 2016, Mike Murach & Associates, Inc.
Introduction to Computer CC111
Key Ideas from day 1 slides
Microprocessor and Assembly Language
Understand the Programming Process
Assembler, Compiler, Interpreter
© 2016, Mike Murach & Associates, Inc.
What Is a Program? A program is like an algorithm, but describes a process that is ready or can be made ready to run on a real computer Retrieved from:
2018, Fall Pusan National University Ki-Joune Li
Understand the Programming Process
Assembler, Compiler, Interpreter
Programming Language Basics
A programming language
An Introduction to Programming with C++ Fifth Edition
An Overview of C.
Programming Logic and Design Eighth Edition
Presentation transcript:

C-Language : Basic Concepts 2013, Fall Pusan National University Ki-Joune Li

Basic Concepts Plan Computer Programming Languages and C- Language Programming Procedure A Sample Program Programming Assignment - 1

C-Language: A Computer Programming Language Program Communication between human and computer Program: A sequence of instructions to a computer Programming Language: Syntax and Grammar of Program Cf. Natural Language ComputerProgrammer Instructions Sequence of Instructions: Computer Program

C-Language: A Computer Programming Language C-Language Developed in 1970s Initially designed and developed for UNIX Becomes a most popular computer programming language In comparison with other languages Relatively close to machine language Easy to handle hardware and systems Computer Engineer: Should be a native speaker of C-Language

Programming Procedure Step 1: Design Design Structures and Algorithms of the program Step 2: Editing and Coding Editing a program With an editing or programming environment Ex. Vi, emacs in Unix, MS visual studio, etc.. Step 3: Compile Translation of a program to (executable) machine code Compiler Step 4: Execute and Debug

Programming Procedure Example Design Visual C/C++ EditingCompile MS-Windows Sample.c Execution Sample.obj Sample.exe Results

A Sample Program #include main() { float a,b,c; /* ax 2 + bx + c=0 */ float x1,x2; double D; /* input coefficients */ printf( “ Input a b c : ” ); scanf( “ %f %f %f ”, &a, &b, &c); if(a==0) { if(b==0) { if(c==0) printf( “ Any real number\n ” ); else printf( “ No Solution\n ” ); } else { /* b!=0 */ x1= -c/a; printf( “ Solution x=%f\n ”, x1); } else { /* a!=0 */ D = doubleb*b-4.0*a*c; if(D<0) printf( “ No Solution\n ” ); else if(D==0) { x1=-b/(2.0*a); printf( “ Solution x=%f\n ”, x1); } else { x1=(-b+sqrt(D))/(2.0*a); x2=(-b-sqrt(D))/(2.0*a); printf(Solution x1=%f x2=%f\n ”,x1,x2); } Block

3. Sample Program #include main() { float a,b,c; /* ax 2 + bx + c=0 */ float x1,x2; double D; /* input coefficients */ printf( “ Input a b c : ” ); scanf( “ %f %f %f ”, &a, &b, &c); if(a==0) { if(b==0) { if(c==0) printf( “ Any real number\n ” ); else printf( “ No Solution\n ” ); } else { /* b!=0 */ x1= -c/a; printf( “ Solution x=%f\n ”, x1); } else { /* a!=0 */ D = doubleb*b-4.0*a*c; if(D<0) printf( “ No Solution\n ” ); else if(D==0) { x1=-b/(2.0*a); printf( “ Solution x=%f\n ”, x1); } else { x1=(-b+sqrt(D))/(2.0*a); x2=(-b-sqrt(D))/(2.0*a); printf(Solution x1=%f x2=%f\n ”,x1,x2); } Variable Value

3. Sample Program #include main() { float a,b,c; /* ax 2 + bx + c=0 */ float x1,x2; double D; /* input coefficients */ printf( “ Input a b c : ” ); scanf( “ %f %f %f ”, &a, &b, &c); if(a==0) { if(b==0) { if(c==0) printf( “ Any real number\n ” ); else printf( “ No Solution\n ” ); } else { /* b!=0 */ x1= -c/a; printf( “ Solution x=%f\n ”, x1); } else { /* a!=0 */ D = doubleb*b-4.0*a*c; if(D<0) printf( “ No Solution\n ” ); else if(D==0) { x1=-b/(2.0*a); printf( “ Solution x=%f\n ”, x1); } else { x1=(-b+sqrt(D))/(2.0*a); x2=(-b-sqrt(D))/(2.0*a); printf(Solution x1=%f x2=%f\n ”,x1,x2); } Type Declaration

3. Sample Program #include main() { float a,b,c; /* ax 2 + bx + c=0 */ float x1,x2; double D; /* input coefficients */ printf( “ Input a b c : ” ); scanf( “ %f %f %f ”, &a, &b, &c); if(a==0) { if(b==0) { if(c==0) printf( “ Any real number\n ” ); else printf( “ No Solution\n ” ); } else { /* b!=0 */ x1= -c/a; printf( “ Solution x=%f\n ”, x1); } else { /* a!=0 */ D = doubleb*b-4.0*a*c; if(D<0) printf( “ No Solution\n ” ); else if(D==0) { x1=-b/(2.0*a); printf( “ Solution x=%f\n ”, x1); } else { x1=(-b+sqrt(D))/(2.0*a); x2=(-b-sqrt(D))/(2.0*a); printf(Solution x1=%f x2=%f\n ”,x1,x2); } Statement

3. Sample Program #include main() { float a,b,c; /* ax 2 + bx + c=0 */ float x1,x2; double D; /* input coefficients */ printf( “ Input a b c : ” ); scanf( “ %f %f %f ”, &a, &b, &c); if(a==0) { if(b==0) { if(c==0) printf( “ Any real number\n ” ); else printf( “ No Solution\n ” ); } else { /* b!=0 */ x1= -c/a; printf( “ Solution x=%f\n ”, x1); } else { /* a!=0 */ D = doubleb*b-4.0*a*c; if(D<0) printf( “ No Solution\n ” ); else if(D==0) { x1=-b/(2.0*a); printf( “ Solution x=%f\n ”, x1); } else { x1=(-b+sqrt(D))/(2.0*a); x2=(-b-sqrt(D))/(2.0*a); printf(Solution x1=%f x2=%f\n ”,x1,x2); } Control Flow

3. Sample Program #include main() { float a,b,c; /* ax 2 + bx + c=0 */ float x1,x2; double D; /* input coefficients */ printf( “ Input a b c : ” ); scanf( “ %f %f %f ”, &a, &b, &c); if(a==0) { if(b==0) { if(c==0) printf( “ Any real number\n ” ); else printf( “ No Solution\n ” ); } else { /* b!=0 */ x1= -c/a; printf( “ Solution x=%f\n ”, x1); } else { /* a!=0 */ D = doubleb*b-4.0*a*c; if(D<0) printf( “ No Solution\n ” ); else if(D==0) { x1=-b/(2.0*a); printf( “ Solution x=%f\n ”, x1); } else { x1=(-b+sqrt(D))/(2.0*a); x2=(-b-sqrt(D))/(2.0*a); printf(Solution x1=%f x2=%f\n ”,x1,x2); } Condition

3. Sample Program #include main() { float a,b,c; /* ax 2 + bx + c=0 */ float x1,x2; double D; /* input coefficients */ printf( “ Input a b c : ” ); scanf( “ %f %f %f ”, &a, &b, &c); if(a==0) { if(b==0) { if(c==0) printf( “ Any real number\n ” ); else printf( “ No Solution\n ” ); } else { /* b!=0 */ x1= -c/a; printf( “ Solution x=%f\n ”, x1); } else { /* a!=0 */ D = doubleb*b-4.0*a*c; if(D<0) printf( “ No Solution\n ” ); else if(D==0) { x1=-b/(2.0*a); printf( “ Solution x=%f\n ”, x1); } else { x1=(-b+sqrt(D))/(2.0*a); x2=(-b-sqrt(D))/(2.0*a); printf(Solution x1=%f x2=%f\n ”,x1,x2); } Assignment

3. Sample Program #include main() { float a,b,c; /* ax 2 + bx + c=0 */ float x1,x2; double D; /* input coefficients */ printf( “ Input a b c : ” ); scanf( “ %f %f %f ”, &a, &b, &c); if(a==0) { if(b==0) { if(c==0) printf( “ Any real number\n ” ); else printf( “ No Solution\n ” ); } else { /* b!=0 */ x1= -c/a; printf( “ Solution x=%f\n ”, x1); } else { /* a!=0 */ D = doubleb*b-4.0*a*c; if(D<0) printf( “ No Solution\n ” ); else if(D==0) { x1=-b/(2.0*a); printf( “ Solution x=%f\n ”, x1); } else { x1=(-b+sqrt(D))/(2.0*a); x2=(-b-sqrt(D))/(2.0*a); printf(Solution x1=%f x2=%f\n ”,x1,x2); } Operator Operator precedence : ( ) > *, / > …

3. Sample Program #include main() { float a,b,c; /* ax 2 + bx + c=0 */ float x1,x2; double D; /* input coefficients */ printf( “ Input a b c : ” ); scanf( “ %f %f %f ”, &a, &b, &c); if(a==0) { if(b==0) { if(c==0) printf( “ Any real number\n ” ); else printf( “ No Solution\n ” ); } else { /* b!=0 */ x1= -c/a; printf( “ Solution x=%f\n ”, x1); } else { /* a!=0 */ D = doubleb*b-4.0*a*c; if(D<0) printf( “ No Solution\n ” ); else if(D==0) { x1=-b/(2.0*a); printf( “ Solution x=%f\n ”, x1); } else { x1=(-b+sqrt(D))/(2.0*a); x2=(-b-sqrt(D))/(2.0*a); printf(Solution x1=%f x2=%f\n ”,x1,x2); } Input/Output

Basic Concepts of Sample Program Block : { … } Value, Variable Type Declaration : integer, float, double, etc. Statement and Semi-colon (“;”) Control Flow : if.. else if … else Condition Assignment (“=“) Operator, Operator Precedence Function Input and Output with printf and scanf