7.-Introduction-to-C
7.-Introduction-to-C
TO PROGRAMMING
2
programming language.
be simple ones like we discussed above Calculating simple interest, given
(adding 2 numbers, rounding off a number) principal, rate and time.
or complex ones which may involve a Calculating the average return on a
sequence of multiple instructions stock over the last 5 years.
The above 2 tasks require complex
Programming is a way to tell calculations. They cannot usually
be expressed in simple instructions
computers to do a specific task. like adding 2 numbers, etc.
Why should you learn
Computer
Programming?
Programming is fun: Using Programming,
you can create your own games, your
personal blog/profile page, a social
networking site like Facebook, a search
engine like Google or an e-commerce
platform like Amazon! Won’t that be fun?
Imagine creating your own game and putting
it on Play Store and getting thousands and
thousands of downloads!
Why should you learn
Computer
Programming?
The backbone of a Technology
Company: The backbones of today’s
technology companies like Google, Facebook,
Microsoft, Apple, Amazon, and many others,
are giant computer programs written by a
collaboration of thousands of skilled
programmers. If you have the right business
acumen, knowing programming can help you
create the next big tech company.
Why should you learn
Computer
Programming?
Pretty good salary: Computer
Programmers are paid extremely well almost
all across the world. Top programmers in
Silicon Valley make millions of dollars every
year. Quite a few companies offer to start
salaries as high as $100,000 per year.
C
PROGRAMMING
C is a procedural programming
language.
It was initially developed by Dennis Ritchie
in the year 1972. It was mainly developed as
a system programming language to write an
operating system.
int main()
{
Body of Program
}
Variable Declaration:
Syntax Error - a syntax error is an error in the syntax of a sequence of characters or tokens
that is intended to be written in a particular programming language.
Syntax - Syntax refers to the rules that define the structure of a language. Syntax in computer
programming means the rules that control the structure of the symbols, punctuation, and words
of a programming language.
Example of Syntax in C:
Display a message:
printf(“Put your Message Here”);
SCENARIO:
SAMPLE PROGRAM THAT PRINTS HELLO WORLD:
NOW LET US APPLY THE PREVIOUS TOPIC WE DISCUSS
#include<stdio.h>
START Step 1: Start main()
{
Step 2: Display Hello World printf(“Hello
Display World”);
“Hello World”
Step 3: Stop }
Output:
End Hello World
ESCAPE SEQUENCE IN C
An escape sequence is a sequence of characters used in formatting
the output and are not displayed while printing text on to the
screen, each having its own specific function.
1.\n (New line) – We use it to shift the cursor control to the new line
2.\t (Horizontal tab) – We use it to shift the cursor to a couple of spaces to the right in the
same line.
3.\r (Carriage Return) – We use it to position the cursor to the beginning of the current line.
4.\\ (Backslash) – We use it to display the backslash character.
5.\’ (Apostrophe or single quotation mark) – We use it to display the single-quotation mark.
6.\” (Double quotation mark)- We use it to display the double-quotation mark.
7.\0 (Null character) – We use it to represent the termination of the string.
8.\? (Question mark) – We use it to display the question mark. (?)
9.\nnn (Octal number)- We use it to represent an octal number.
10.\xhh (Hexadecimal number) – We use it to represent a hexadecimal number.
11.\v (Vertical tab)
12.\b (Backspace)
13.\e (Escape character)
14.\f (Form Feed page break)
print(“Biliran\n”);
print(“Province\n”);
print(“State\n”);
print(“University\n”);
MAKE A FLOWCHART, PSEUDOCODE, CODE AND OUTPUT OF THE
FOLLOWING SCENARIOSi:
1. Create a Program that display your Name, Age, Address and your Favorite pet.
2. Create a program that display this output:
*
* *
* * *
* * * *
* * * **
* * * ***
* * * ****
Submit your output in Google Classroom
Deadline is until 10pm only
Always include your name at the end of the program:
SAMPLE OUTPUT
#include<stdio.h>
START Step 1: Start main()
{
Step 2: Display Hello World printf(“Hello
Display World”);
“Hello World”
Step 3: Stop printf(“Submitted by:
Jonicio Dacuya”)
} Output:
End
Screenshot Hello World