C programming 1 Flashcards
this takes material from "C programming a modern approach" book , and sololearn app
which system is C language a product of?
UNIX operating system
what was UNIX programmed in originally? explain the history behind the changes
it was originally programmed in Assembly like the other operating systems of that time.
then thompson decided that a higher level language is required for further development of UNIX so he designed a small language named B which was based on BCPL.
after Ritchie joined the UNIX project he started working on an extended version of B and named it “NB” or new B , later as the language diverged more from B he changed the name to “C” , they rewrote the UNIX in C .
what language was B based on ?
it was based on BCPL
what was the old name for C language?
it was “NB” or New B ,at first
who made the C language?
Dennis Ritchie
where was UNIX made and by whom ?
at Bell Laboratories by Ken Thompson , Dennis Ritchie and others.
name some 4 C based programming languages and how they relate to C.
C++ : includes all C features of C but adds others like classes and more features to support OOP .
Java : is based on C++ and therefore inherits many of C features.
C# :is a more recent language, derived from C++ and Java .
Perl : was a fairly simple language but as it has grown it adopted many features from C language.
name 3 philosophies of the C language design.
1: it is a low level language.
2: it is a small language.
3: it is a permissive language.
what is meant that C language is low level? how is that important for systems programming?
it provides access to low level concepts like addresses and bytes which other languages try to hide.
it also provides operations that correspond closely to machines built-in instructions. so it can be fast as systems cannot afford to be slow.
how was C languages features kept small?
it was kept small by relying on a library of standard functions.
name 6 strengths of C language.
1: its efficient , regarding speed and running with limited memory.
2: its portable .
3: its powerful , it has a large collections of datatypes and operators which gives it power and it can do more with fewer lines.
4: its flexible , as it imposes few restrictions on the use of its features.
5 :has a standard library which has many useful functions.
6: integrated with UNIX and UNIX-like operating systems.
how did C become portable?
1 - it was associated with UNIX and ISO/ANSI early which prevented it from splintering into numerous dialects.
2 - its compliers are small and easily written which makes them widely available.
3- has many features that support portability.
name 3 weaknesses for C langauge
1 : its programs can be error prone.
2 : its programs can be hard to understand.
3 : its programs can be hard to modify.
name one reason C programs can be error prone.
its flexibility can make it error prone
name 6 ways you can ensure more effective use of C language .
1 : learn its pitfalls and avoid them.
2 : use software tools that make programs more reliable , like Lint for error analysis.
3 : take advantage of existing code libraries.
4 : adopt a sensible set of code conventions.
5 : avoid tricks and overly complex code.
6 : stick to standard.
what does Lint do?
Lint is a tool to check for potential errors .
how to get “Lint” tool ?
it is included as Splint in many linux distributions “secure programming lint” , and it can be download from splint.org for free.
what steps the C program takes to become executable ?
preprocessing : the program is given first to the preprocessor which obeys commands preceded by “#” which are known as directives , and makes modifications.
compiling ; the compiler translates to the machine instructions making “object code” .
linking : .the linker includes additional code to make the program executable .
in gnu/linux how to make the executable version of the file “pun.c” get named “pun” ?
we enter the following command in the command line while in the same directory as the file:
gcc -o pun pun.c
what is an IDE and what can it do?
IDE = integrated development environment.
it can edit , compile , link ,execute and debug a program without leaving the environment .
what are functions in C language , generally?
they are like building blocks of programs , known in other languages as subroutines and procedures .
what are the two types of functions in C based on their source?
there are two :
those written by the programmer
and
those provided as a part of C implementation which are known as library functions.
what is a statement in C ?
its a command to be run when the program is run .
what are storage locations called in C ?
Variables