Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Introduction to C Programming, Slides of C programming

An introduction to the c programming language, covering topics such as the history and development of c, the strengths and weaknesses of the language, and the importance of algorithms in programming. It discusses the different types of programming languages, including low-level languages like machine language and assembly language, as well as high-level languages like c. The document also explains the process of compiling a c program and the key concepts of algorithms, including sequence, selection, and repetition. Additionally, it presents a case study on designing and developing a c program to calculate the circumference of a circle, and discusses common programming errors. Overall, this document serves as a comprehensive introduction to the fundamentals of c programming, making it a valuable resource for students or individuals interested in learning this widely-used programming language.

Typology: Slides

2023/2024

Uploaded on 05/06/2024

ata-turkoglu
ata-turkoglu 🇹🇷

1 document

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to C Programming
CNG 230
Lecture - 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Introduction to C Programming and more Slides C programming in PDF only on Docsity!

Introduction to C Programming

CNG 230 Lecture - 1

Programming Languages

  • (^) Computer program: data and instructions used to operate a computer and produce a specific result - (^) A program or set of programs is called software.
  • (^) Programming: writing instructions in a language that the computer can respond to and that other programmers can understand
  • (^) Programming language: set of instructions that can be used to construct a program

Programming languages II

  • (^) Assembly language
    • (^) Symbolic notations to machine language are referred to as assembly language.
    • (^) Each class of computer such as IBM PC, Apple and Hewlett-Packard has different machine languages LOAD first ADD second MUL factor STORE answer
    • (^) Programming languages that use this type of symbolic notation are referred as assembly language.

Assemblers

Program translation

How a C program is compiled?

Development of C

  • (^) History of C…” Professional Programmer’s Language !”
    • Developed by Denis M. Ritchie at AT&T Bell Labs in 1972 as a systems programming language
    • Used to develop UNIX
    • Used to write modern operating systems
    • Hardware independent (portable)
  • Standardization
    • Many slight variations of C existed, and were incompatible
    • Committee formed to create a "unambiguous, machine independent“ definition
    • Standard created in 1989, updated in 1999

Algorithms

  • (^) Before a C program is written, a programmer must clearly understand what the data is to be used, the desired result or output , and the steps to be used to produce the result.
  • (^) The steps selected to produce the result is referred to as an algorithm.
  • (^) “What method will you use to solve the given problem?”

The Power of Algorithms

  • (^) Algorithms can be written to solve a multitude of (sometimes very complex) problem
  • (^) Yet they are made up of careful combinations of very simple operations
  • (^) Simple operations are combined in the following ways
    • (^) sequence - one operation (or group of operations) directly follows another
    • (^) condition (selection) - an operation (or group of operations) is executed, or not executed, based on the results of a yes/no (true/false) decision
    • (^) repetition (loop) - an operation (or group of operations) is executed repeatedly, a given number of times, or until a given condition is true

Algorithms - Pseudocode

  • (^) When English phrases are used to describe the algorithm (the processing steps), the description is called pseudocode.
  • (^) Example: Set n equal to 100 Set a equal to 1 Set b equal to 100 Calculate sum = n(a+b)/ Display the sum

Case Study: Design and Development

The circumference, C, of a circle is given by the formula C = 2 x PI x r, where PI is the contast 3.14, and r is the radius of the Circle. Using this information, write a C program to calculate the circumference of a circle that has 2-inch radius.

Common Programming Errors

  • (^) Rushing to write and execute a program without spending sufficient time on learning about the problem and designing and appropriate algorithm;
  • (^) Forgetting to backup a program;
  • (^) Not understanding that computers respond only to explicitly defined algorithms.

Summary

  • (^) There are low-level (machine, assembly language) and high-level languages (procedural, object-oriented);
  • (^) C is a high level language;
  • (^) The steps selected to produce the result is referred to as an algorithm.
  • (^) Sequence, selection and repetition are key to algorithms;
  • (^) Main steps include:
    • (^) Get the inputs to the problem
    • (^) Calculate the desired outputs
    • (^) Report the results of a calculation