Structured programming (C-Language)

¡Supera tus tareas y exámenes ahora con Quizwiz!

Sample C program

...

The "main" function

...

Libraries

Are useful functions and symbols that are predefined by the C language (standard libraries). You must include stdio.h if you want to use the printf and scanf library functions. #include <stdio.h>

What is C language?

C language is a high level programming language developed in 1972 by Dennis Ritchie at the AT and T Bell Laboratories. It is the most commonly used programming language for writing system software. It is machine independent: by minimal change in source code, can be compiled in a wide variety of platform and operating system.

Comments

Comments provide supplementary information making it easier for us to understand the program, but are ignored by the C compiler. Two forms: /**/ anything in between (multiple lines) //- before the end of a line. Comments are used to create program documentation( information that help others read and understand the program ) The start of the program should consist of a comment that includes programmers name, date of the current version, and a brief description of what the program does. Always comment your code!

# include

Is used to include other source files into your source file. Give the program access to a library.

Why C language?

Many companies/ research projects do all their programming in C. Looks good on your resume. Small, compact code. Produces optimized programs that run faster. Low-level access to computer memory via machine addresses and pointers. Low-level (Bit Wise) programming readily available. Can be compiled on a variety of computers.

Relational operators

Or use to compare numbers to german relative order.

What's missing?

Poor error detection which can make it difficult to use for the beginner: No automatic garbage collection. No bounds checking of arrays and allocated memory segments. No exception handling. No native support for multithreading and networking, though these facilities are provided by popular libraries. No standard libraries for graphics and several other application programming needs.

Preprocessor directives

Preprocessor directives are commands to give instructions to the C preprocessor. Preprocessor is a system program that modifies a CE program prior to its compilation. Preprocessor directives begins with a #, ex: #Include, #define.

General form of a C program

Preprocessor directives. Main function heading. { Declarations. Executable statements. }

#define

The #define directive instructs the preprocessor to replace each occurrence of a text by a particular constant value before compialation. #define replaces all occurrences of the text you specify what value you specify. #define KMS_PER_MILES 1.60 #define PI 3.14159


Conjuntos de estudio relacionados

Life and Health Insurance AD Study Quiz

View Set

RN COMMUNITY HEALTH NURSING—CHAPTER 6: Communicable Diseases, Disasters, and Bioterrorism

View Set

MBE 2015 CONTRACTS PAROL EVIDENCE RULE

View Set

chapter four: dynamics of microbial growth

View Set

*To Kill A Mockingbird (All Words)

View Set

Chapter 31: The Nurse in Schools

View Set

Biceps Brachii, Coracobrachialis, Brachialis, Brachioradialis, Triceps Brachii, Anconeus Study Guide,

View Set