Coe 251 Unit 1
Coe 251 Unit 1
J. Yankey
[email protected]// 0264665015
Jan 2014
Introducing the C Programming
language
Programming and Problem Solving
-From Problem to Solution
• What is a
program?
• What is an
algorithm?
Programming Languages
• You need to learn the meaning of words and how to use them (keywords)
HIGH-LEVEL LANGUAGE
HARDWARE
• Why do we have to invent another language like C to learn
programming?
1. C PHP Java
4. C++ SQL C#
8. Python C# Ruby
9. Perl C++
11. Python
12. C
How does the computer know the rules of the
language?
• The Backus-Naur Form
• Sentence = Subject Verb Object
• Subject = Noun
• Object = noun
• Verb = love
• Verb = eat
• Noun = I
• Noun = Adwoa
• Noun = C Programming
• (Replace all non-terminals until we are left with only terminals)
Grammar for C expressions
}
('pagecreate', '#wrapper_question'
SYNTAX
type_name variable_name_1, variable_name_2, . . .;
EXAMPLE
int count, numberOfStudents, number_of_people;
double average;
SYNTAX
#define identifier value
const type variable = value;
EXAMPLE
#define LENGTH 10
const int LENGTH = 10;
2.
#include <stdio.h>
#define LENGTH 10
#define WIDTH 5
#define NEWLINE '\n'
main()
{
int area;
area = LENGTH * WIDTH;
printf("value of area : %d", area);
printf("%c", NEWLINE);
}
WHAT IS THE OUTPUT?
3.
#include <stdio.h>
int main()
{
const int LENGTH = 10;
const int WIDTH = 5;
const char NEWLINE = '\n';
int area;
return 0;
}
Thank You