Introduction to C Programming Lesson 2 PDF
Document Details
Uploaded by AuthenticFoxglove
Polytechnic University of the Philippines
Tags
Summary
This document is a lesson on the introduction to C programming, covering concepts such as programming language, semantics, syntax, and basic structure examples, including exercises for practice. This introductory lesson is suitable for an undergraduate-level computer science course.
Full Transcript
Introduction to C Language Software Programming Language Programming Language High-Level Language Low-Level Language C? High-Level C Mid-Level Language Language Low-...
Introduction to C Language Software Programming Language Programming Language High-Level Language Low-Level Language C? High-Level C Mid-Level Language Language Low-Level Language History of C C was created in 1972 by Dennis Ritchie at the Bell Labs in USA as part of UNIX operating system. What is the predecessor of C? In 1960, "Basic Combined Programming Language" also called as "B" language was developed by Martin Richards at Cambridge University. “Hello World” C Programming B was modified by Dennis Ritchie and implemented at Bell Laboratory in 1972 which is now called "C.” C is used by most of the operating systems: Compiler For the source code to be executed, there is a need for a compiler. Compiler Semantics Vs. Syntax Semantics Syntax Semantics refers to the logic of the Syntax refers to the rules that define program the structure of a language. Can be applied to all programming Specific to a certain programming language. language. Basic Syntax and Structure of C Programs C Basic Syntax and Structure C Basic Syntax and Structure Header Files C Basic Syntax and Structure Main Function C Basic Syntax and Structure Braces C Basic Syntax and Structure printf C Basic Syntax and Structure Semicolon C Basic Syntax and Structure return 0 indicates successful execution C Basic Syntax and Structure C Format C Format Statements are Indentation is terminated with ignored by the #include semicolons compiler int main(void){ C is case sensitive - all Library functions printf(“Hello World\n”); keywords and are lowercase printf(“It is a great day!”); Standard. return(0); } Strings are Newlines are placed in double handled via \n quotes. Library Functions : https://www.ibm.com/docs/en/i/7.3?topic=extensions-standard-c-library-functions-table-by-name Exercises 1. Create a program to print your name and address on separate lines (Use multiple printf functions). 2. Choose a short poem or quote and write a program to print it to the screen, formatted nicely by using only one printf function. 3. Display the piece of abstract art shown below, using just a single printf command. ***** **|** *|.|* |...|..... Exercises 4. Display the piece of abstract art shown below, using just a single printf command. /\ / \ < > \ / \/