EL6483: Brief Overview of C Programming Language

Size: px
Start display at page:

Download "EL6483: Brief Overview of C Programming Language"

Transcription

1 EL6483: Brief Overview of C Programming Language EL6483 Spring 2016 EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

2 Preprocessor macros, Syntax for comments Macro definitions // define M to be 1 #define M 1 // define FILENAME to be "file.txt" #define FILENAME "file.txt" // define a macro max to calculate max of two quantities #define max(x,y) ((X) > (Y)? (X) : (Y)) Whereever these macro names are referred to in the C/C++ code, the names are simply replaced by the corresponding substitutions. Including other files (e.g., header files). Example: #include <math.h> Syntax for comments: // Single line comments /* Multi-line comments * Comments that span over multiple lines Still within the comment */ EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

3 Conditional compilation using the preprocessor Include a piece of code only under a certain condition : preprocessor directives #ifdef, #endif, #if (defined ), #else, #elif, etc. Examples: #ifdef INCLUDE_FUNCTION1_DEFN // only if INCLUDE_FUNCTION1_DEFN is defined void function1(); #else // only if INCLUDE_FUNCTION1_DEFN is not defined void function2(); #endif #if (defined INCLUDE_MATH_FUNCTIONS && \ defined USE_DOUBLES_FOR_TRIG_FUNCTIONS) double sin(double); double cos(double); #endif \ at the end of a line is used for line-continuation (i.e., to split a long line into multiple smaller lines). A frequent use of conditional compilation is for include guards in header files (so as to include the contents of the header file only once even if the header file is #include d multiple times). Example (e.g., for a file, file1.h): #ifndef FILE1_H #define FILE1_H // function prototypes, etc., in file1.h #endif EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

4 Variables and Datatypes Remember that C is case-sensitive. int a; is different from int A; Basic datatypes include char, int, float, double, etc. signed and unsigned variants Aggregates of variables of basic data types can be defined as structures (struct). Arrays of multiple values of a data type, e.g., int arr[10]; Pointer types, e.g., int *p_int; float *p_float; // pointers to values of different data types are themselves different data types, i.e., an int * is different from a float *; also, function pointers are different data types. To define an aggregate of multiple variables, but using the same memory for each of the variables, use union data types. Example: union { int i; float f; } u; u is a union of an int and a float, i.e., u can be regarded as an int in which case the data is accessed as u.i or u can be regarded as a float in which case the data is accessed as u.f. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

5 Operators Arithmetic operators: +, -, *, /, %, ++, --, etc. Comparison operators: ==,!=, >, >=, etc. Logical operators:!, &&,, etc. Bitwise operators: ~, &,, ^,», «, etc. Assignment operators: =, +=, -=, &=, etc. Array subscript and pointer operators: [], *, &, ->,., etc. Other operators: (), ternary operator (? :), sizeof, type cast operator, etc. Operators in C and C++: http: // en. wikipedia. org/ wiki/ Operators_ in_ C_ and_ C% 2B% 2B EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

6 Bitwise operations Bitwise operation Symbol (in C) AND & OR XOR ^ NOT ~ Left shift << Right shift >> Bitwise operations are commonly used to set various flags in an embedded system. For example, consider a variable L that represents a control register for a voltage sensor. If it is defined that bit 0 (i.e., the right-most bit) specifies whether the voltage range of the voltage sensor with bit 0 being 0 corresponding to 0-10V and bit 0 being 1 corresponding to ± 10 V, then to select the ± 10 V option without changing any of the other bits in L, we could write (in C): L = L 0x1; EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

7 Bitwise operations Some examples of bitwise operations: 0x05 & 0x01 = 0x01 0x05 0x02 = 0x07 0x05 ^ 0x01 = 0x04 0x05 << 2 = 0x14 0x05 >> 1 = 0x02 Example: If we have an integer variable named L and we want to set bit 1 (with bit 0 being the right-most bit) to 0 without changing the other bits, we can write (in C): or equivalently: L &= ( 0x02); L = L & ( 0x02); EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

8 Functions A group of statements; takes a set of parameters (could be void) and returns a value (could be void). Function declaration is just the prototype (often in header files); function prototype is also sometimes called function signature; function definition is the implementation. Example of function prototype: int sum(int n1, int n2); Example of function definition: int sum(int n1, int n2) { return (n1+n2); } Funtion prototype just specifies the types of the arguments to the function and the type of the return value. A function declaration can appear multiple times in a program (the declarations should all be identical however). But, a function definition should occur only once; if a function is defined multiple times (e.g., two separate functions with the same name in two different files), that will result in a link-time error (conceptually, one exception to this is a weak function definition which can be overridden by a function definition of the same name in another file weak visibility will be discussed later). EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

9 Functions A function can call itself (recursive functions). For example, factorial of a number can be calculated using the following recursive function: int factorial(int k) { if (k == 1) return 1; else return k * factorial(k-1); } Since function calls typically push variables (e.g., local variables and/or function parameters, link register values, etc.) on the stack, recursive functions can result in stack overflow if the function call nesting becomes too deep. For example, calling factorial(10000); with the recursive implementation of factorial might result in a stack overflow. Depending on the expected sizes of the function arguments, it might be better to use a non-recursive implementation. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

10 Pointers Pointers point at a memory location (i.e., a pointer is like an address to a memory location). Pointer variables hold the address of a memory location. Example: int k1; int *k_ptr = &k1; // k_ptr is a pointer to the memory location that contains k1 An address is taken using the symbol &. Pointers are dereferenced using the symbol *. Example: int k1 = 5; int *k_ptr = &k1; // k_ptr now contains address of k1 (i.e., points to k1) int q = *k_ptr; // q now contains 5 int *k_ptr2 = k_ptr; // k_ptr2 also now points to k1 You can have pointers to pointers. Example: int *k_ptr; int **s = &k_ptr; // s now contains the address of k_ptr (i.e., points to k_ptr). EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

11 Pass-by-value and pass-by-pointer Arguments to C functions are passed by value (i.e., copies of the arguments are passed to the function). Example: int f(int i, int k); When f is called, for example, as\ int i1 = 1; int k1 = 2; f(i1,k1); copies of i1 and k1 are passed to f. Modifying the values of the passed arguments (i and k) inside the function f will not modify the values of i1 and k1. If an argument to a function is a pointer, then the value of what the pointer points to can be changed from within the function using the pointer. Example: int g(int i, int *p_int); // *p_int can be changed from within the function g Passing a pointer as an argument is still pass-by-value (the pointer is passed by value), but approximates pass-by-reference since the value of what the pointer points to can be changed from within the function. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

12 typedef The keyword typedef is used to define an alias for a type. Example: typedef int AliasForInt; // AliasForInt is now an alias for int AliasForInt a; // AliasForInt can be used anywhere int can void f(aliasforint i); // AliasForInt can be used anywhere int can typedef int * IntPtr; // IntPtr is now an alias for pointer to int IntPtr k; // k is now of type IntPtr, i.e., k is a pointer to an int EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

13 Function pointers The address of a function can be stored in a function pointer. Examples: If f is a function declared as int f(int);, we can define a pointer to this function as: int (*f_ptr)(int) = &f; // f_ptr is now a pointer to the function f The & is optional when defining a function pointer, i.e., you could also write int (*f_ptr)(int) = f; A function pointer can be used to call the function that it points to. For example, with f_ptr defined as shown above, you can write: int k = f_ptr(3); // call the function pointed to by the function pointer f_ptr EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

14 Function pointers Function pointers are commonly used to implement callback functions. The entries of an interrupt vector table can also be thought of function pointers (addresses to functions). Callback functions are commonly used in embedded systems programming to improve modularity (i.e., reduced coupling) of the different layers of code. For example, an application layer code can register a callback (as a function pointer) to be called by a driver layer code that reads a peripheral device. Then, the driver layer code is independent of the specific application layer code; also, the same application layer code can potentially work with many different hardware devices. Function pointers can also be used to implement generic functions. See for an example. Typedefs can be utilized to simplify function pointer syntax, especially when function pointers are used as arguments for functions. Example: typedef float *(*SomeTypeOfFunction)(float, float); // SomeTypeOfFunction is now an alias for the type corresponding to pointer to a function that takes two float arguments and returns a pointer to a float. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

15 Structs Structs can be used to define a group of variables. Example: struct MyStruct { int a; double d; char c; }; A variable of type struct MyStruct can be defined as: struct MyStruct s; A struct can be a function parameter, e.g., void f(struct MyStruct s1); We can have pointers to structs, e.g., struct MyStruct *ps; void f1(struct MyStruct *ps1); EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

16 Typedefs for structs A typedef can be used to avoid having to keep typing struct whenever we want to refer to the datatype. typedef struct _MyStruct { int a; double d; char c; } MyStruct; With this typedef, we can use MyStruct as an alias for struct _MyStruct, i.e., MyStruct s; void f(mystruct s1); MyStruct *ps; void f(mystruct *ps1); EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

17 extern The extern keyword is used to access a symbol defined in another translation unit Example: if an int is defined in a file a.c as int k;, this int can be accessed from another file b.c as: extern int k; Without the extern keyword, the int k; lines in a.c and b.c would define two separate global variables with the same name, resulting in a linker error. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

18 static The static keyword has two different meanings depending on the context. Static variable inside a function Example: void f() { static int a = 0; a ++; } The variable a is initialized once at the beginning and retains its value between multiple calls to the function f. Without the keyword static, the variable a would be allocated each time the function is called (and would be set to 0). With the keyword static, the variable a increments each time f is called, so, after f is called 5 times, a becomes 5. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

19 static The static keyword has two different meanings depending on the context. Static global variable or function With keyword static, a global variable or function is only visible within the translation unit (file scope) in which it is defined. Examples: static int k; // global variable (defined outside any function); due to static, this variable is only visible at file scope static void f(int a); // f is only visible at file scope EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

20 register Example: register int k; // tells the compiler to try to put this variable in a processor register A register is much faster to read/write than a location in memory. The register keyword tells the compiler that this variable is used often and would be good to have in a register to reduce time for read/write operations for this variable. The compiler may not be able to accommodate the request to put the variable in a register and may ignore this keyword. Since the variable might actually be allocated in a register, and since you cannot take the address of a register, taking the address of a register variable (as, for example, &k) is not allowed. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

21 volatile Example: volatile int k; // tells the compiler that this variable might change outside of the control of the program tells the compiler to not try to optimize accesses to this variable (i.e., actually access it from memory whenever a line of code refers to it even if it appears that the variable cannot have been changed since its last access) volatile is often used to access I/O peripheral registers (e.g., a peripheral status register for an analog-to-digital converter indicating that data is ready, etc.); here, the data in these variables (memory-mapped I/O) would change due to other hardware events (i.e., outside the control of the program running on the processor) volatile is also used for variables that are changed from within an interrupt service routine; from the point of view of the main loop of the program, these variables appear to change outside its control. Example: volatile int new_data_received; // global variable updated from within an interrupt service routine EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

22 const The const keyword defines a variable as a constant, i.e., tells the compiler that it will not be modified by the program. Example: const int k = 5; // k will not be assigned to again within the program Note: A const variable might be possibly modified by using a pointer to the variable: const int k = 1; *((int *)(&k)) = 2;. This is however typically not recommended. Writing const with a pointer specifies that the data pointed to by the pointer is a constant. Example: const int *q; // q is a pointer to a constant integer, i.e., *q cannot be modified via the pointer q. const pointer: a pointer that is constant (i.e., the pointer cannot be made to point to anything else). Example: int a; int *const q = &a; // q will not point to anything else. *q can be assigned to however. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

23 const const volatile : A variable can be both const and volatile. The most common example is a hardware register that might be modified by an external hardware device but will not be modified by the program. Examples: const volatile int a; const volatile int *q; A const pointer to a const : when the data pointed to by the pointer cannot be changed and the pointer value itself cannot be changed (i.e., the pointer cannot be made to point to something else). Example: const int *const q = &k; // k cannot be changed via the pointer q and q cannot be made to point to something else. If the const keyword is used for some parameters in a function declaration, it specifies that the function does not change those arguments. Example: void f(const int *r1, int *r2); // function f might change data pointed to by r2, but does not change data pointed to by r1 EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

24 Variable and function scopes Variables can have various scopes (i.e., visibilities). Global scope: a variable defined outside any function body, e.g., int a; // outside any function body A variable at global scope is visible everywhere (globally) in the sense that if there is any other global variable with the same name somewhere else, there will be a symbol conflict. To actually access the variable from another translation unit, use the keyword extern. File scope: To restrict the visibility of a variable to only the translation unit in which it is defined, use the keyword static. Local scope (block scope): a variable defined inside a brace-enclosed block is only visible within the block. Example: void f() { int a = 3; // a is only visible inside function f if (a > 1) { int b = 4; // b is only visible inside the if block } } EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

25 Variable and function scopes Functions can have global scope or local file scope. Functions have global scope by default and are visible from other translation units in the program. To make a function have file scope (i.e., visible only within the translation unit), use the static keyword. Example: static int sqr(int a) {return a*a;} // sqr is visible only within this translation unit. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

26 Endianness Memory in a computer is addressed in bytes, i.e., each byte of memory has its own address. When storing a variable of a data type that is larger than 1 byte, there are two possibilities: storing the least significant byte first (in the lowest memory address) or storing the most significant byte first. Endianness refers to the order in which the bytes of a variable that is larger than 1 byte is stored. Little-endian: least significant byte is stored first (i.e., at the lowest memory address) Big-endian: most significant byte is stored first (i.e., at the lowest memory address) For example, if a 32-bit integer has bytes B3, B2, B1, and B0 with B3 being the most significant byte and B0 being the least significant byte, a little-endian processor would store the bytes in the sequence B0 B1 B2 B3 in memory and a big-endian processor would store the bytes in the sequence B3 B2 B1 B0 in memory. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

27 Byte swapping to exchange data between computers with different endianness conventions When we exchange data (e.g., using a serial port) between computers with different endianness conventions (or when we need to, for example, read a file stored with a different endianness), we need to swap bytes. For example, this means that if we have a 32-bit integer with byte sequence B3 B2 B1 B0 with B3 being the most significant byte and B0 being the least significant byte, then we might need to switch it to the byte sequence B0 B1 B2 B3. This can be done using a few different methods, e.g., using union or using bit-shift and OR operators. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

28 Using union to swap order of bytes between little-endian and big-endian A union is like a struct, but uses the same memory for each of its member variables. For example, t y p e d e f union { i n t k ; u n s i g n e d char c [ 4 ] ; } i n t _ c h a r s ; In this union, the int k and the unsigned char c[4] share the same memory (4 bytes). unsigned char is simply 1 unsigned byte (i.e., uint8_t). If we store an int into an instance of this union datatype, we can read back the bytes of the int using the array c[4]. EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

29 Using union to swap order of bytes between little-endian and big-endian To swap the order of bytes in a 32-bit integer B3 B2 B1 B0, we can write a function as: i n t swap_bytes ( i n t i ) { i n t _ c h a r s i_c1 ; i n t _ c h a r s i_c2 ; i_c1. k = i ; // copy b y t e s from i_c1 to i_c2 swapping the byte o r d e r i_c2. c [ 0 ] = i_c1. c [ 3 ] ; i_c2. c [ 1 ] = i_c1. c [ 2 ] ; i_c2. c [ 2 ] = i_c1. c [ 1 ] ; i_c2. c [ 3 ] = i_c1. c [ 0 ] ; r e t u r n i_c2. k ; } EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

30 Using bit-shift and OR operators to swap order of bytes between little-endian and big-endian To swap the order of bytes in a 32-bit integer B3 B2 B1 B0, we can also use bit-shift and OR operators to write a function as: i n t swap_bytes ( i n t i ) { r e t u r n ( i << 24) ( ( i >> 24) & 0 x f f ) ( ( i << 8) & 0 x 0 0 f f ) ( ( i >> 8) & 0 x f f 0 0 ) ; } EL6483 EL6483: Brief Overview of C Programming Language Spring / 30

Some Basic Concepts EL6483. Spring EL6483 Some Basic Concepts Spring / 22

Some Basic Concepts EL6483. Spring EL6483 Some Basic Concepts Spring / 22 Some Basic Concepts EL6483 Spring 2016 EL6483 Some Basic Concepts Spring 2016 1 / 22 Embedded systems Embedded systems are rather ubiquitous these days (and increasing rapidly). By some estimates, there

More information

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above

More information

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

COMP322 - Introduction to C++ Lecture 02 - Basics of C++ COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

C Syntax Out: 15 September, 1995

C Syntax Out: 15 September, 1995 Burt Rosenberg Math 220/317: Programming II/Data Structures 1 C Syntax Out: 15 September, 1995 Constants. Integer such as 1, 0, 14, 0x0A. Characters such as A, B, \0. Strings such as "Hello World!\n",

More information

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program Syntax What the Compiler needs to understand your program 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line Possibly replacing it with other

More information

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

CprE 288 Introduction to Embedded Systems Exam 1 Review.  1 CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

COMP322 - Introduction to C++

COMP322 - Introduction to C++ COMP322 - Introduction to C++ Winter 2011 Lecture 2 - Language Basics Milena Scaccia School of Computer Science McGill University January 11, 2011 Course Web Tools Announcements, Lecture Notes, Assignments

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

Functions. Functions are everywhere in C. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

Functions. Functions are everywhere in C. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR 1 Functions Functions are everywhere in C Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Introduction Function A self-contained program segment that carries

More information

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

CMPE-013/L. Introduction to C Programming

CMPE-013/L. Introduction to C Programming CMPE-013/L Introduction to C Programming Bryant Wenborg Mairs Spring 2014 What we will cover in 13/L Embedded C on a microcontroller Specific issues with microcontrollers Peripheral usage Reading documentation

More information

QUIZ. What are 3 differences between C and C++ const variables?

QUIZ. What are 3 differences between C and C++ const variables? QUIZ What are 3 differences between C and C++ const variables? Solution QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Solution The C/C++ preprocessor substitutes mechanically,

More information

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

More information

TDDE18 & 726G77. Functions

TDDE18 & 726G77. Functions TDDE18 & 726G77 Functions Labs update No more one time password. We will note who have demonstrated during the lab and register this in webreg. Use the terminal to send in your lab! Dont use Visual studio

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Pointers Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) Pointers February 29, 2012 1

More information

Motor Industry Software Reliability Association (MISRA) C:2012 Standard Mapping of MISRA C:2012 items to Goanna checks

Motor Industry Software Reliability Association (MISRA) C:2012 Standard Mapping of MISRA C:2012 items to Goanna checks Goanna 3.3.2 Standards Data Sheet for MISRA C:2012 misrac2012-datasheet.pdf Motor Industry Software Reliability Association (MISRA) C:2012 Standard Mapping of MISRA C:2012 items to Goanna checks The following

More information

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup starting in 1979 based on C Introduction to C++ also

More information

C Language Advanced Concepts. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

C Language Advanced Concepts. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff C Language Advanced Concepts 1 Switch Statement Syntax Example switch (expression) { } case const_expr1: statement1; case const_expr2: : statement2; default: statementn; The break statement causes control

More information

Introduction to C++ with content from

Introduction to C++ with content from Introduction to C++ with content from www.cplusplus.com 2 Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

BLM2031 Structured Programming. Zeyneb KURT

BLM2031 Structured Programming. Zeyneb KURT BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Puntatori Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 5, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction to C October

More information

Embedded Systems - FS 2018

Embedded Systems - FS 2018 Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Embedded System Companion Introduction As its name indicates, the Embedded System Companion has been

More information

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

CS Programming In C

CS Programming In C CS 24000 - Programming In C Week Two: Basic C Program Organization and Data Types Zhiyuan Li Department of Computer Science Purdue University, USA 2 int main() { } return 0; The Simplest C Program C programs

More information

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below: QUIZ 1. Explain the meaning of the angle brackets in the declaration of v below: This is a template, used for generic programming! QUIZ 2. Why is the vector class called a container? 3. Explain how the

More information

CS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their

More information

Topic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History

Topic 6: A Quick Intro To C. Reading. goto Considered Harmful History Topic 6: A Quick Intro To C Reading Assumption: All of you know basic Java. Much of C syntax is the same. Also: Some of you have used C or C++. Goal for this topic: you can write & run a simple C program

More information

QUIZ. What is wrong with this code that uses default arguments?

QUIZ. What is wrong with this code that uses default arguments? QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

INTRODUCTION 1 AND REVIEW

INTRODUCTION 1 AND REVIEW INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.

More information

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE? 1. Describe History of C++? The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. One of the languages Stroustrup had the opportunity

More information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

More information

The C Programming Language Guide for the Robot Course work Module

The C Programming Language Guide for the Robot Course work Module The C Programming Language Guide for the Robot Course work Module Eric Peasley 2018 v6.4 1 2 Table of Contents Variables...5 Assignments...6 Entering Numbers...6 Operators...7 Arithmetic Operators...7

More information

Programming in C. main. Level 2. Level 2 Level 2. Level 3 Level 3

Programming in C. main. Level 2. Level 2 Level 2. Level 3 Level 3 Programming in C main Level 2 Level 2 Level 2 Level 3 Level 3 1 Programmer-Defined Functions Modularize with building blocks of programs Divide and Conquer Construct a program from smaller pieces or components

More information

Syntax and Variables

Syntax and Variables Syntax and Variables What the Compiler needs to understand your program, and managing data 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line

More information

A S H O R T I S H O V E R V I E W O F T H E A N S I C P R O G R A M M I N G L A N G U A G E

A S H O R T I S H O V E R V I E W O F T H E A N S I C P R O G R A M M I N G L A N G U A G E A S H O R T I S H O V E R V I E W O F T H E A N S I C P R O G R A M M I N G L A N G U A G E IDENTIFIERS Identifiers are names of variables, functions, defined types, structures and unions, enumeration

More information

Functions. Prof. Indranil Sen Gupta. Dept. of Computer Science & Engg. Indian Institute t of Technology Kharagpur. Introduction

Functions. Prof. Indranil Sen Gupta. Dept. of Computer Science & Engg. Indian Institute t of Technology Kharagpur. Introduction Functions Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute t of Technology Kharagpur Programming and Data Structure 1 Function Introduction A self-contained program segment that

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ... Why Pointers Pointers They provide the means by which functions can modify arguments in the calling function. They support dynamic memory allocation. They provide support for dynamic data structures, such

More information

G52CPP C++ Programming Lecture 6. Dr Jason Atkin

G52CPP C++ Programming Lecture 6. Dr Jason Atkin G52CPP C++ Programming Lecture 6 Dr Jason Atkin 1 Last lecture The Stack Lifetime of local variables Global variables Static local variables const (briefly) 2 Visibility is different from lifetime Just

More information

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science The component base of C language Nguyễn Dũng Faculty of IT Hue College of Science Content A brief history of C Standard of C Characteristics of C The C compilation model Character set and keyword Data

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine

More information

Programming in C - Part 2

Programming in C - Part 2 Programming in C - Part 2 CPSC 457 Mohammad Reza Zakerinasab May 11, 2016 These slides are forked from slides created by Mike Clark Where to find these slides and related source code? http://goo.gl/k1qixb

More information

Chapter 2. Procedural Programming

Chapter 2. Procedural Programming Chapter 2 Procedural Programming 2: Preview Basic concepts that are similar in both Java and C++, including: standard data types control structures I/O functions Dynamic memory management, and some basic

More information

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE COURSE TITLE C LANGUAGE DETAILED SYLLABUS SR.NO NAME OF CHAPTERS & DETAILS HOURS ALLOTTED 1 INTRODUCTION TO C LANGUAGE About C Language Advantages of C Language Disadvantages of C Language A Sample Program

More information

by Pearson Education, Inc. All Rights Reserved.

by Pearson Education, Inc. All Rights Reserved. Let s improve the bubble sort program of Fig. 6.15 to use two functions bubblesort and swap. Function bubblesort sorts the array. It calls function swap (line 51) to exchange the array elements array[j]

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

Pointer Basics. Lecture 13 COP 3014 Spring March 28, 2018

Pointer Basics. Lecture 13 COP 3014 Spring March 28, 2018 Pointer Basics Lecture 13 COP 3014 Spring 2018 March 28, 2018 What is a Pointer? A pointer is a variable that stores a memory address. Pointers are used to store the addresses of other variables or memory

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

C Language Programming

C Language Programming Experiment 2 C Language Programming During the infancy years of microprocessor based systems, programs were developed using assemblers and fused into the EPROMs. There used to be no mechanism to find what

More information

ME 461 C review Session Fall 2009 S. Keres

ME 461 C review Session Fall 2009 S. Keres ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help

More information

Have examined process Creating program Have developed program Written in C Source code

Have examined process Creating program Have developed program Written in C Source code Preprocessing, Compiling, Assembling, and Linking Introduction In this lesson will examine Architecture of C program Introduce C preprocessor and preprocessor directives How to use preprocessor s directives

More information

QUIZ How do we implement run-time constants and. compile-time constants inside classes?

QUIZ How do we implement run-time constants and. compile-time constants inside classes? QUIZ How do we implement run-time constants and compile-time constants inside classes? Compile-time constants in classes The static keyword inside a class means there s only one instance, regardless of

More information

FUNCTIONS POINTERS. Pointers. Functions

FUNCTIONS POINTERS. Pointers. Functions Functions Pointers FUNCTIONS C allows a block of code to be separated from the rest of the program and named. These blocks of code or modules are called functions. Functions can be passed information thru

More information

Topic 6: A Quick Intro To C

Topic 6: A Quick Intro To C Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions

More information

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

QUIZ. Source:

QUIZ. Source: QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Ch. 4: Data Abstraction The only way to get massive increases in productivity is to leverage off other people s code. That

More information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26 COSC 2P95 Procedural Abstraction Week 3 Brock University Brock University (Week 3) Procedural Abstraction 1 / 26 Procedural Abstraction We ve already discussed how to arrange complex sets of actions (e.g.

More information

Chapter 2 - Introduction to C Programming

Chapter 2 - Introduction to C Programming Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic

More information

Variables. Data Types.

Variables. Data Types. Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting

More information

C Programming Language (Chapter 2 of K&R) Variables and Constants

C Programming Language (Chapter 2 of K&R) Variables and Constants C Programming Language (Chapter 2 of K&R) Types, Operators and Expressions Variables and Constants Basic objects manipulated by programs Declare before use: type var1, var2, int x, y, _X, x11, buffer;

More information

Structures, Unions Alignment, Padding, Bit Fields Access, Initialization Compound Literals Opaque Structures Summary. Structures

Structures, Unions Alignment, Padding, Bit Fields Access, Initialization Compound Literals Opaque Structures Summary. Structures Structures Proseminar C Grundlagen und Konzepte Michael Kuhn Research Group Scientific Computing Department of Informatics Faculty of Mathematics, Informatics und Natural Sciences University of Hamburg

More information

Functions. (transfer of parameters, returned values, recursion, function pointers).

Functions. (transfer of parameters, returned values, recursion, function pointers). Functions (transfer of parameters, returned values, recursion, function pointers). A function is a named, independent section of C/C++ code that performs a specific task and optionally returns a value

More information

Computers Programming Course 5. Iulian Năstac

Computers Programming Course 5. Iulian Năstac Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction

More information

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++ CHAPTER 9 C++ 1. WRITE ABOUT THE BINARY OPERATORS USED IN C++? ARITHMETIC OPERATORS: Arithmetic operators perform simple arithmetic operations like addition, subtraction, multiplication, division etc.,

More information

COMP26120: Algorithms and Imperative Programming. Lecture 5: Program structuring, Java vs. C, and common mistakes

COMP26120: Algorithms and Imperative Programming. Lecture 5: Program structuring, Java vs. C, and common mistakes COMP26120: Algorithms and Imperative Programming Lecture 5: Program structuring, Java vs. C, and common mistakes Lecture outline Program structuring Functions (defining a functions, passing arguments and

More information

CSE 333 Autumn 2013 Midterm

CSE 333 Autumn 2013 Midterm CSE 333 Autumn 2013 Midterm Please do not read beyond this cover page until told to start. A question involving what could be either C or C++ is about C, unless it explicitly states that it is about C++.

More information

Ch. 3: The C in C++ - Continued -

Ch. 3: The C in C++ - Continued - Ch. 3: The C in C++ - Continued - QUIZ What are the 3 ways a reference can be passed to a C++ function? QUIZ True or false: References behave like constant pointers with automatic dereferencing. QUIZ What

More information

PESIT-BSC Department of Science & Humanities

PESIT-BSC Department of Science & Humanities LESSON PLAN 15PCD13/23 PROGRAMMING IN C AND DATA Course objectives: STRUCTURES The objective of this course is to make students to learn basic principles of Problem solving, implementing through C programming

More information

Appendix G C/C++ Notes. C/C++ Coding Style Guidelines Ray Mitchell 475

Appendix G C/C++ Notes. C/C++ Coding Style Guidelines Ray Mitchell 475 C/C++ Notes C/C++ Coding Style Guidelines -0 Ray Mitchell C/C++ Notes 0 0 0 0 NOTE G. C/C++ Coding Style Guidelines. Introduction The C and C++ languages are free form, placing no significance on the column

More information

Contents Lecture 3. C Preprocessor, Chapter 11 Declarations, Chapter 8. Jonas Skeppstedt Lecture / 44

Contents Lecture 3. C Preprocessor, Chapter 11 Declarations, Chapter 8. Jonas Skeppstedt Lecture / 44 Contents Lecture 3 C Preprocessor, Chapter 11 Declarations, Chapter 8 Jonas Skeppstedt (js@cs.lth.se) Lecture 3 2014 1 / 44 C Preprocessor Predefined macros Macro replacement Conditional inclusion Source

More information

C/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock)

C/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock) C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 By the end of this lecture, you will be able to identify the

More information

C/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for

C/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 1 By the end of this lecture, you will be able to identify

More information

Fundamentals of Programming. Lecture 12: C Structures, Unions, Bit Manipulations and Enumerations

Fundamentals of Programming. Lecture 12: C Structures, Unions, Bit Manipulations and Enumerations Fundamentals of Programming Lecture 12: C Structures, Unions, Bit Manipulations and Enumerations Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department

More information

C Programming Review CSC 4320/6320

C Programming Review CSC 4320/6320 C Programming Review CSC 4320/6320 Overview Introduction C program Structure Keywords & C Types Input & Output Arrays Functions Pointers Structures LinkedList Dynamic Memory Allocation Macro Compile &

More information

UNIT-2 Introduction to C++

UNIT-2 Introduction to C++ UNIT-2 Introduction to C++ C++ CHARACTER SET Character set is asset of valid characters that a language can recognize. A character can represents any letter, digit, or any other sign. Following are some

More information

15 FUNCTIONS IN C 15.1 INTRODUCTION

15 FUNCTIONS IN C 15.1 INTRODUCTION 15 FUNCTIONS IN C 15.1 INTRODUCTION In the earlier lessons we have already seen that C supports the use of library functions, which are used to carry out a number of commonly used operations or calculations.

More information

Functions in C C Programming and Software Tools

Functions in C C Programming and Software Tools Functions in C C Programming and Software Tools N.C. State Department of Computer Science Functions in C Functions are also called subroutines or procedures One part of a program calls (or invokes the

More information

ELEC 377 C Programming Tutorial. ELEC Operating Systems

ELEC 377 C Programming Tutorial. ELEC Operating Systems ELE 377 Programming Tutorial Outline! Short Introduction! History & Memory Model of! ommon Errors I have seen over the years! Work through a linked list example on the board! - uses everything I talk about

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables

More information

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead. Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public

More information

Princeton University COS 333: Advanced Programming Techniques A Subset of C90

Princeton University COS 333: Advanced Programming Techniques A Subset of C90 Princeton University COS 333: Advanced Programming Techniques A Subset of C90 Program Structure /* Print "hello, world" to stdout. Return 0. */ { printf("hello, world\n"); -----------------------------------------------------------------------------------

More information

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS C Programming C SYLLABUS COVERAGE Introduction to Programming Fundamentals in C Operators and Expressions Data types Input-Output Library Functions Control statements Function Storage class Pointer Pointer

More information

Functions. Autumn Semester 2009 Programming and Data Structure 1. Courtsey: University of Pittsburgh-CSD-Khalifa

Functions. Autumn Semester 2009 Programming and Data Structure 1. Courtsey: University of Pittsburgh-CSD-Khalifa Functions Autumn Semester 2009 Programming and Data Structure 1 Courtsey: University of Pittsburgh-CSD-Khalifa Introduction Function A self-contained program segment that carries out some specific, well-defined

More information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

G52CPP C++ Programming Lecture 8. Dr Jason Atkin

G52CPP C++ Programming Lecture 8. Dr Jason Atkin G52CPP C++ Programming Lecture 8 Dr Jason Atkin 1 Last lecture Dynamic memory allocation Memory re-allocation to grow arrays Linked lists Use -> rather than. pcurrent = pcurrent -> pnext; 2 Aside: do not

More information