You are on page 1of 16

COMPUTER

SCIENCE UNIT 1
C PROGRAMMING
P R E S E N T E D B Y:

KEITH SMITH

JAELAN THOMAS

D’ANDRE WILLIAMS

A L B E RT T H O M A S
Introduction to C – Start of the
First Segment
• C is a powerful procedural-based programming language developed in 1972 by Dennis Ritchie within the
halls of Bell Telephone Laboratories. The C programming language was originally developed for use with
the UNIX platform and has since spread to many other systems and applications.
Why do people use C?

• The C Programming Language was developed for writing operating systems software and compilers. The
rapid expansion of C over various types of computers (sometimes called hard-ware platforms) led to many
variations that were similar but often incompatible. This was a serious problem for programmers who
needed to develop code that would run on several platforms. It became clear that a standard version of C
was needed.
How do you run a C program?

To execute a C program, the programmer has to go through six phases for the program to be executed. These
six phases are: Edit, Preprocess, Compile, Link, Load and Execute.
• An object code is a compiler that translates the C program into machine language code.

• The C Preprocesser obeys special commands called preprocesser directives, which indicates that certain
manipulations are to be performed on the program before compilation. The Preprocesser program processes
the code.

• In order to create a C program, a text editor is required.

• A linker links the object code with the code for the missing functions to produce and executable image.
• A compiler creates object code and stores it on a disk.

• Comments help to identify program purpose and explain complex routines.

• Source code is generally understood to mean programming statements that are created by a programmer
with a text editor or a visual programming tool and then saved in a file known as the source file.
END OF FIRST SEGMENT
SECOND SEGMENT
• The purpose of the main function is responsible for starting the execution and termination of the program.

• Reserved words are words that have pre-defined uses and cannot be used for any other purpose in a C
program. Examples of Reserved words in C program are: If, For, Do, Auto, Break, Short, Return, While, etc.

• The parentheses following the reserved word “main” indicates that the main is a function and the
parentheses are used to encompass information to be passed to the main() function.

• The left brace ({) tells us the opening of a function in a program.

• C program statement are used to control program execution and functionality.


• The function call in the hello world is main().

• The function call has no arguments.

• The data type of the argument is int.

• It indicates that the program has executed successfully, it is not a must.

• Syntax Error is an error in which the programmer doesn’t follow the rules of the program.

• Logic Error is an error in the way the program works, the program can run but does not do what it is expected to
do.
• Run Time error is an error that occurs when a program you’re using or writing crashes or produces a wrong
output.
Error #1:Missing program block identifiers

• #include <stdio.h>

main()

printf("Welcome to C Programming\n");

}
Error #2: Missing Statement
Terminators
#include <stdio.h>

main()

printf("Welcome to C Programming\n")

}
Error #3: Invalid Preprocesser
Directive
#include <sdio.h>

main()

printf("Welcome to C Programming\n");

}
Error #4:Invalid escape sequences

#include <stdio.h>

main()

printf("Welcome to C Programming\m");

}
Error #5:Invalid comment blocks

#include <stdio.h>

main()

*/ This demonstrates a common error with comment blocks /*

printf("Welcome to C Programming\n");

You might also like