basicsCC 1
basicsCC 1
basicsCC 1
Basic Concepts
Basic functions of each language: Input,
output, math, decision, repetition
Types of errors: Syntax errors, logic errors,
runtime errors.
Debugging
Machine language, assembly language, high
level languages
Procedural Programming
Data Element
Procedure A
1-3
Procedure B
Procedural languages
Global variables
Primitive data types, Arrays, Records/Structures
lots of functions/procedures/modules
Uniqueness of names requirement
SW Complexity
reality
SW
Complexity
SW complexity?
SW Complexity
SW
Complexity
ideal
Object-Oriented Programming
Programming
Interface
Object
Attributes (data)
typically private to this object
Other
objects
Methods
(behaviors / procedures)
1-8
C vs. C++
C++ is backward compatible with C
C++ supports OOP
C++ standard library contains lot more
functionality
Improved I/O mechanism
Lot of new header files
C is very efficient, C++ is close too.
Java
unique
C standard library
http://en.wikipedia.org/wiki/C_standard_library
stdio.h: scanf(), printf(), getchar(), putchar(), gets(),
puts(),
stdlib.h: atof(), atoi(), rand(), srand(), malloc(), free(),
math.h: sin(), cos(), sqrt(),
string.h: strcpy(), strcmp(),
ctype: isdigit(), isalpha(), tolower(), toupper()
main()
{
main()
{
int i, array[10], array2[10];
printArray(int *arr)
{
int i;
for(i=0 ; i<10 ; i++)
printf("%d\n",arr[i]);
second()
{
int i, array[10], array2[10];
printArray(int *arr)
{
int i;
for(i=0 ; i<10 ; i++)
printf("%d\n",arr[i]);
Things to observe
file2.java
file3.java
filen.java
file2.c
file3.c
filen.c
Debugging : gdb
Compile with g option to use the debugger.
Most used commands:
run
list [method name]
break [line_number]
step
next
continue
print [variable]