Home   MosaicPresentation format
<http://cnfolio.com/IntroToComputingTopic01Print>
Introduction to Computing – B142L

Getting started with C programming

Academic year 2011/12



Objectives:
  1. Outline of unit syllabus and coursework
  2. Advantages of software programming
  3. Characteristics of the C programming language
  4. Parts of a C program






Websites for unit information and coursework



Unit information is online at:


Coursework is online at:






The original computing device



An abacus:
  • Where is the hardware?
  • Where is the software?
  • Where is the data storage?
  • Who were the programmers?
abacus






First general purpose electronic computer



Electronic Numerical Integrator and Computer (ENIAC) in 1946:
  • Where is the hardware?
  • Where is the software?
  • Where is the data storage?
  • Who were the programmers?
Electronic Numerical Integrator and Computer (ENIAC) in 1946






The most common model for computers



John von Neumann is credited with the design for a stored-program computer. This concept that has been applied to mainstream computer hardware since 1945.

von Neumann architecture





Hardware and software



Computing is the automation of tasks that benefit from repetition.
  • History shows that there are risks from automation, too.
  • Computing innovation initially focused on hardware development.


Software are solutions for problems that can be implemented using computers.
  • Software often implement an algorithm or procedure.
  • Software are compiled into instructions for specific types of computing hardware.
Bloomberg terminal






Why do we need software for these products?









Why use a programming language?



A processor instruction is an electronic circuit.

A processor instruction is an electronic circuit


Common categories of processor instructions:


A programming language is a set of symbols (characters) and syntax rules that can be used to describe detailed instructions for a microprocessor or a virtual machine.


We use programming languages because they allow:






The C programming language



The C programming language was developed in 1972 at AT&T Bell Labs (related article).







Steps to create a C program











Review questions




Development of computers


From 1946 until the late 1980s, innovations in computing were mostly in which area?

Software
Networking
Hardware
Average rating is  






Review questions




Development of computers


Which area of computing has not increased due to innovations?

Amount of energy consumed by microprocessors
Space available to store programs during execution
Processing power of personal computers
Number of programmers required to write software
Average rating is  






Review questions




Software development life cycle


A compiler converts source code into what type of object?

list of processor instructions
hardware product
standard output






Review questions




Software development life cycle


In which situation would you be required to re-compile a program?

Different instruction sets
Different microprocessors
Different operating systems






C is a procedural language







Standard error (stderr) is often directed to the same destination as standard output.






Writing C programs




The main() function is required for all C programs.






Writing C programs




This preprocessor directive is used to include the source code from the stdio.h header file into the current program.






Writing C programs




C programs use 2 types of statements:






Writing C programs




Function calls require a pair of parentheses after the name of the function.






Writing C programs




Comments start with /* and continue until it reaches a matching */ end.



Do not use C++, Java or PHP style comments, which use a double forward slash at the indicate the start of comments.
// Do not use comments in this style. They reduce portability between C compilers.







Reserved keywords in the C language




Reserved keywords are often highlighted with a different color in the editor and may not be used as names of functions or data.

autoconstdoublefloatintshortstructunsigned
breakcontinueelseforlongsignedswitchvoid
casedefaultenumgotoregistersizeoftypedefvolatile
chardoexternifreturnstaticunionwhile







Software development life cycle



It is important to use the version control and comments in your Mosaic coursework page to record your progress.








Review questions




C language syntax


Why is C considered a procedural programming language?

Programs run one procedure after another
Programs run one statement after another
Programs run one function after another
Average rating is  






Review questions




C language syntax


Comments must be written at the top of a program before the main() function.

True
False






Review questions




C language syntax


Which item in the list below is not considered to be part of the C language syntax.

statements
reserved keywords
libraries
functions