A note on the field of programming, how to learn programming and training courses for programming, learning programming from scratch to professionalism, learning programming for beginners to professionalism, programming languages
,• Structure of a program
– See ~zxu2/Public/ACMS40212/C++_basics/basics.cpp
Compilation Stages
– To see how the code looks after pre-processing, type
icc –A –E basics.cpp
2
,• Aggregates
1. Variables of the same type can be put into arrays or multi-D arrays, e.g.,
char letters[50], values[50][30][60];
Remark: C has no subscript checking; if you go to the end of an array, C won't
warn you.
2. Variables of different types can be grouped into a structure.
typedef struct {
int age;
int height;
char surname[30];
} person;
…
person fred;
fred.age = 20;
Remark: variables of structure type can not be compared.
Do not do:
person fred, jane;
…
if(fred == jane)
{
printf(“the outcome is undefined”);
} 3
, Pointers
• A variable can be viewed as a specific block of memory in
the computer memory which can be accessed by the
identifier (the name of the variable).
– int k; /* the compiler sets aside 4 bytes of memory (on a PC) to hold the value
of the integer. It also sets up a symbol table. In that table it adds the symbol k
and the relative address in memory where those 4 bytes were set aside. */
– k = 8; /*at run time when this statement is executed, the value 8 will be
placed in that memory location reserved for the storage of the value of k. */
• With k, there are two associated values. One is the value of the
integer, 8, stored. The other is the “value” or address of the memory
location.
• The variable for holding an address is a pointer variable.
int *ptr; /*we also give pointer a type which refers to the type of data stored at
the address that we will store in the pointer. “*” means pointer to */
4
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller mebrahim_fahmy. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $6.39. You're not tied to anything after your purchase.