12 CREATING NEW TYPES
|
|
- Trevor White
- 5 years ago
- Views:
Transcription
1 Lecture 12 CREATING NEW TYPES of DATA Typedef declaration Enumeration Structure Bit fields Uninon
2 Creating New Types Is difficult to solve complex problems by using programs written with only fundamental types of data. In C++, the programmer can create any type needed, and each of these new types can have all the functionality and power of the built-in types.
3 Typedef The typedef keyword is used to create a new name for an existing data type. In effect, typedef creates a synonym. For example, the statement: typedef int integer; creates integer as a synonym for int.
4 Typedef Other examples: typedef char string[20]; String becomes an alias for an array of 20 chars string name; is the same as: char name[20];
5 Typedef typedef unsigned int uint; uint becomes an alias for unsigned int uint x; is the same as: unsigned int x;
6 Typedef typedef int bool; bool becomes an alias for int. bool OK; is the same as: int OK;
7 Enumerations enum keyword is used to define a set of constants of type int we use the syntax: enum [<enum_name>] {<constant_name> [= <value>],...} [var_list];
8 For example, Enumerations enum bool {false, true}; bool isodd; introduces an user-defined type (i.e. the type bool) for representing boolean values, two enumerators which have integral values starting from 0 (i.e., false is 0 and true is 1)
9 Enumerations enum days {sun=1, mon, tues, wed, thur, fri, sat}; days oneday; establishes an integer type named days, a variable oneday of type days, and a set of enumerators starting from 1 (sun is 1, mon is 2, etc.).
10 Structures provide a way to represent a collection of data of different types Arrays (and also pointers to data lists) are a method of grouping a lot of data together, but all data elements must be of the same type. If you need grouping elements of different types, you must use structures.
11 A structure is a collection of one or more variables grouped under a single name A structure can contain any of C++'s data types, including arrays and other structures.
12 The syntax used to define a new data type with struct (in C++) is: struct <type-name> { <type> <variable-name[, variablename,...]> ;... } <structure-variables> ;
13 The syntax used to define a new data type with struct (in C) is: typedef struct { <type> <variable-name[, variablename,...]> ;... } <type-name>;
14 Though both <type-name> and <structurevariables> are optional, one of the two must appear. Each variable within a structure is called a member of the structure or field of the structure.
15 For example, Structures struct exstru { int m1; char m2; float m3; } var1, var2 ;
16 Other example, struct coord { int x; }; int y; The following statement declares two instances of type coord: coord point1, point2;
17 Individual structure members can be used like other variables of the same type. Members of a structure are accessed using the structure member operator (.), also called the dot operator or record selector. You can assign values to members of var1: var1.m1=22; var1.m2= x ; var1.m3=12.75;
18 Initializing Structures struct mystru { int m1; char m2; float m3; } myvar = { 99, y, } ;
19 Pointers to Structures You can declare and use pointers to structures, just as it can declare pointers to any other data storage type Next statement declares a pointer to type mystru: mystru * pstru;
20 The pointer pstru can be used only if it was initialized. Because a pointer needs a memory address to point to, you must declare an instance of type mystru before anything can point to it. Here's the declaration: exstru myvar; Now you can perform the pointer initialization: pstru = &myvar;
21 There are two methods to use this pointer: First method uses the indirection operator (*). (*pstru).m1 = 100; The second method uses the indirect membership operator (->) pstru -> m1 = 100;
22 Structures That Contain Structures struct coord { int x; int y; }; struct rectangle { coord topleft; coord bottomright; };
23 Allocation of memory for structure rectangle rectangle box; box.topleft.x box.topleft.y
24 Structures That Contain Arrays struct student { char name[10]; int marks[4] float average; };
25 Organization of structure student student stud1;
26 Pointers as Structure Members struct mystru { int *value; int *rate; } myvar; myvar.value = &cost; myvar.rate = &interest;
27 Pointers and Arrays of Structures A C++ array can contain elements of any data types, so the elements of an array can be of type structure. For example, if you define the structure coord: struct coord { int x, y; }; you can declare an array as follows: coord points[100];
28 Organization of array points with elements of type coord points[0] = points[99]; points[0].x = points[99].x;
29 Passing Structures as Arguments to Functions Like any data types, a structure can be passed as an argument to a function. You can use any style of passing arguments to a function: pass-by-value, pass-by-address and pass-by-reference.
30 For example, struct complex {double re,im;}; void print_complex(complex c); void read_complex(complex *c); complex sum_complex(complex &a, complex &b);
31 Bit Fields A bit field is an element of a structure that is defined in terms of bits. Using a special type of struct definition, you can declare a structure element that can range from 1 to 15 bits in length.
32 Bit Fields struct bit_field { unsigned m1 : 1; unsigned m2 : 4; unsigned m3 : 1; unsigned m4 : 10; } myvariable;
33 Bit Fields Representation of Bit Fields in Memory
34 Unions Unions are similar to structures. An union is declared and used in the same ways that a structure is. An union differs from a structure in that only one of its members can be used at a time because all the members of a union occupy the same area of memory. Data members of one union are mapped to the same address within its object.
35 Unions The size of an object of one union is, therefore, the size of its largest data member. union myunion { char c; int i; float f;} var1;
C# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals
C# Types Industrial Programming Lecture 3: C# Fundamentals Industrial Programming 1 Industrial Programming 2 Value Types Memory location contains the data. Integers: Signed: sbyte, int, short, long Unsigned:
More informationIndustrial Programming
Industrial Programming Lecture 3: C# Fundamentals Industrial Programming 1 C# Types Industrial Programming 2 Value Types Memory location contains the data. Integers: Signed: sbyte, int, short, long Unsigned:
More informationby: Lizawati, Norhidayah & Muhammad Noorazlan Shah Computer Engineering, FKEKK, UTeM
by: Lizawati, Norhidayah & Muhammad Noorazlan Shah Computer Engineering, FKEKK, UTeM At the end of this chapter, the students should be able to: understand and apply typedef understand and apply structure
More informationLecture10: Structures, Unions and Enumerations 11/26/2012
Lecture10: Structures, Unions and Enumerations 11/26/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction to C 1 Administrative Items Assignment #10 on the course webpage r, long double, etc.
More informationC# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh
C# Fundamentals Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh Semester 1 2018/19 H-W. Loidl (Heriot-Watt Univ) F20SC/F21SC 2018/19
More informationChapter 7: Structuring the Data. Lecture7 1
Chapter 7: Structuring the Data Lecture7 1 Topics Introduction to Structures Operations on Structures Using Structures with Arrays Using Structures with Pointers Passing Structures to and from Functions
More informationProgramming. Structures, enums and unions
Programming Structures, enums and unions Summary } Structures } Declaration } Member access } Function arguments } Memory layout } Array of structures } Typedef } Enums } Unions 2 Idea! } I want to describe
More informationProgramming in C. What is C?... What is C?
Programming in C UVic SEng 265 C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version
More informationProgramming in C. What is C?... What is C?
C Programming in C UVic SEng 265 Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version
More informationProgramming in C UVic SEng 265
Programming in C UVic SEng 265 Daniel M. German Department of Computer Science University of Victoria 1 SEng 265 dmgerman@uvic.ca C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier,
More informationDarshan Institute of Engineering & Technology for Diploma Studies Unit 5
1 What is structure? How to declare a Structure? Explain with Example Structure is a collection of logically related data items of different data types grouped together under a single name. Structure is
More informationLecture 3. The syntax for accessing a struct member is
Lecture 3 Structures: Structures are typically used to group several data items together to form a single entity. It is a collection of variables used to group variables into a single record. Thus a structure
More informationBLM2031 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 informationFeatures 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 informationLecture 12: Data Types (and Some Leftover ML)
Lecture 12: Data Types (and Some Leftover ML) COMP 524 Programming Language Concepts Stephen Olivier March 3, 2009 Based on slides by A. Block, notes by N. Fisher, F. Hernandez-Campos, and D. Stotts Goals
More informationProgramming in Haskell Aug-Nov 2015
Programming in Haskell Aug-Nov 2015 LECTURE 14 OCTOBER 1, 2015 S P SURESH CHENNAI MATHEMATICAL INSTITUTE Enumerated data types The data keyword is used to define new types data Bool = False True data Day
More informationStructures. Today s Goals. Structure Operations. Structure Type Declaration. Struct Instance. typedef. CS246 Lec12. Structures
Today s Goals Section 1 Structures Structures Types and variables typedef structs and pointers Unions Enumerations To group multiple (heterogeneous) variables Similar to Java classes, but not as powerful
More informationECET 264 C Programming Language with Applications. Lecture 13. Structures and Unions
ECET 264 C Programming Language with Applications Lecture 13 Structures and Unions Professor Paul I-Hai Lin lin@ipfw.edu http://www.etcs.ipfw.edu/~lin Prof. Paul I. Lin 1 Lecture 13 Structures and Unions
More informationChapter-8 DATA TYPES. Introduction. Variable:
Chapter-8 DATA TYPES Introduction To understand any programming languages we need to first understand the elementary concepts which form the building block of that program. The basic building blocks include
More informationInput And Output of C++
Input And Output of C++ Input And Output of C++ Seperating Lines of Output New lines in output Recall: "\n" "newline" A second method: object endl Examples: cout
More informationTokens, Expressions and Control Structures
3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type
More informationIntroduction 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 informationIntroduction 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 informationEnumerated Types. Mr. Dave Clausen La Cañada High School
Enumerated Types Mr. Dave Clausen La Cañada High School Enumerated Types Enumerated Types This is a new simple type that is defined by listing (enumerating) the literal values to be used in this type.
More informationa data type is Types
Pointers Class 2 a data type is Types Types a data type is a set of values a set of operations defined on those values in C++ (and most languages) there are two flavors of types primitive or fundamental
More informationIV Unit Second Part STRUCTURES
STRUCTURES IV Unit Second Part Structure is a very useful derived data type supported in c that allows grouping one or more variables of different data types with a single name. The general syntax of structure
More informationUNIT-V. Structures. The general syntax of structure is given below: Struct <tagname> { datatype membername1; datatype membername2; };
UNIT-V Structures Structure is a very useful derived data type supported in c that allows grouping one or more variables of different data types with a single name. The general syntax of structure is given
More informationIntroduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types
Chapter 6 Topics WEEK E FOUR Data Types Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference
More informationIntroduction. Primitive Data Types: Integer. Primitive Data Types. ICOM 4036 Programming Languages
ICOM 4036 Programming Languages Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference Types Data Types This
More informationLaboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information
Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify
More informationC++: Const Function Overloading Constructors and Destructors Enumerations Assertions
C++: Const Function Overloading Constructors and Destructors Enumerations Assertions Const const float pi=3.14159; const int* pheight; // defines pointer to // constant int value cannot be changed // pointer
More informationProgramming Fundamentals (CS-302 )
Programming Fundamentals (CS-302 ) (Structures) Dr. Ihsan Ullah Lecturer Department of Computer Science & IT University of Balochistan 1 Introduction A variable can store one element at a time An array
More informationcar object properties data red travels at 50 mph actions functions containing programming statements Program Program variables functions
1 C++ PROGRAMMERS GUIDE LESSON 1 File: CppGuideL1.doc Date Started: July 12,1998 Last Update: Mar 21, 2002 Version: 4.0 INTRODUCTION This manual will introduce the C++ Programming Language techniques and
More informationData Representation and Storage
Data Representation and Storage Learning Objectives Define the following terms (with respect to C): Object Declaration Definition Alias Fundamental type Derived type Use size_t, ssize_t appropriately Use
More informationM.EC201 Programming language
Power Engineering School M.EC201 Programming language Lecture 13 Lecturer: Prof. Dr. T.Uranchimeg Agenda The union Keyword typedef and Structures What Is Scope? External Variables 2 The union Keyword The
More informationData Representation and Storage. Some definitions (in C)
Data Representation and Storage Learning Objectives Define the following terms (with respect to C): Object Declaration Definition Alias Fundamental type Derived type Use pointer arithmetic correctly Explain
More informationFrancesco Nidito. Programmazione Avanzata AA 2007/08
Francesco Nidito in the Programmazione Avanzata AA 2007/08 Outline 1 2 3 in the in the 4 Reference: Micheal L. Scott, Programming Languages Pragmatics, Chapter 7 What is a type? in the What is a type?
More informationVariables 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 informationG Programming Languages Spring 2010 Lecture 8. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 8 Robert Grimm, New York University 1 Review Last time Types Fun with O Caml 2 Outline Modules Sources: PLP, 3.3.4, 3.3.5, 3.7 Barrett. Lecture notes,
More informationCprE 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 informationCS349/SE382 A1 C Programming Tutorial
CS349/SE382 A1 C Programming Tutorial Erin Lester January 2005 Outline Comments Variable Declarations Objects Dynamic Memory Boolean Type structs, enums and unions Other Differences The Event Loop Comments
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Overview. C# program structure. Variables and Constant. Conditional statement (if, if/else, nested if
More informationComputer Systems Principles. C Pointers
Computer Systems Principles C Pointers 1 Learning Objectives Learn about floating point number Learn about typedef, enum, and union Learn and understand pointers 2 FLOATING POINT NUMBER 3 IEEE Floating
More informationAryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9
Fundamental of C Programming Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Q2. Write down the C statement to calculate percentage where three subjects English, hindi, maths
More informationComputer System and programming in C
Computer System and programming in C 1 C structures: aggregate, yet scalar aggregate in that they hold multiple data items at one time named members hold data items of various types like the notion of
More informationThe syntax of structure declaration is. struct structure_name { type element 1; type element 2; type element n;
Structure A structure is a user defined data type. We know that arrays can be used to represent a group of data items that belong to the same type, such as int or float. However we cannot use an array
More informationPointers, Dynamic Data, and Reference Types
Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple
More informationUNIT-IV. Structure is a user-defined data type in C language which allows us to combine data of different types together.
UNIT-IV Unit 4 Command Argument line They are parameters/arguments supplied to the program when it is invoked. They are used to control program from outside instead of hard coding those values inside the
More informationShort 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 informationIn this session we will cover the following sub-topics: 1.Identifiers 2.Variables 3.Keywords 4.Statements 5.Comments 6.Whitespaces 7.Syntax 8.
In this session we will cover the following sub-topics: 1.Identifiers 2.Variables 3.Keywords 4.Statements 5.Comments 6.Whitespaces 7.Syntax 8.Semantic www.tenouk.com, 1/16 C IDENTIFIERS 1. Is a unique
More informationCSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010
CSE 374 Programming Concepts & Tools Hal Perkins Spring 2010 Lecture 12 C: structs, t linked lists, and casts Where we are We ve seen most of the basic stuff about C, but we still need to look at structs
More informationObject-Oriented Principles and Practice / C++
Object-Oriented Principles and Practice / C++ Alice E. Fischer April 20, 2015 OOPP / C++ Lecture 3... 1/23 New Things in C++ Object vs. Pointer to Object Optional Parameters Enumerations Using an enum
More informationStructures. Dr. Donald Davendra Ph.D. (Department of Computing Science, Structures FEI VSB-TU Ostrava)
Structures Dr. Donald Davendra Ph.D. Department of Computing Science, FEI VSB-TU Ostrava 1/18 Derived and Structured Data Types basic data type - part of the standard language, preprocessor - without parameters,
More informationCS201 - 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 informationCOMP 2355 Introduction to Systems Programming
COMP 2355 Introduction to Systems Programming Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 Functions Similar to (static) methods in Java without the class: int f(int a, int
More informationBasic Types, Variables, Literals, Constants
Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic
More informationStructures and Pointers
Structures and Pointers Comp-206 : Introduction to Software Systems Lecture 11 Alexandre Denault Computer Science McGill University Fall 2006 Note on Assignment 1 Please note that handin does not allow
More informationLecture Notes on Programming Languages
Lecture Notes on Programming Languages 37 Lecture 04: Data Types and Variables All programming languages provide data types. A data type describes a set of data values and a set of predefined operations
More informationDownloaded S. from Kiran, PGT (CS) KV, Malleswaram STRUCTURES. Downloaded from
Downloaded S. from Kiran, www.studiestoday.com PGT (CS) KV, STRUCTURES WHAT IS A STRUCTURE? Structure is a collection of logically related data. It is also a collection of dissimilar datatype. Downloaded
More informationC-types: basic & constructed. C basic types: int, char, float, C constructed types: pointer, array, struct
C-types: basic & constructed C basic types: int, char, float, C constructed types: pointer, array, struct Memory Management Code Global variables in file (module) Local static variables in functions Dynamic
More informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 10 Thomas Wies New York University Review Last class ML Outline Modules Sources: PLP, 3.3.4, 3.3.5, 3.8 McConnell, Steve. Code Complete, Second Edition,
More informationCSE 230 Intermediate Programming in C and C++
CSE 230 Intermediate Programming in C and C++ Bitwise Operators and Enumeration Types Fall 2017 Stony Brook University Instructor: Shebuti Rayana http://www3.cs.stonybrook.edu/~cse230/ Overview Bitwise
More informationCMPE-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 informationBinghamton 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 informationFor each of the following variables named x, specify whether they are static, stack-dynamic, or heapdynamic:
For each of the following variables named x, specify whether they are static, stack-dynamic, or heapdynamic: a) in C++: int* x = new(int); b) in Java: class book { protected string title; book(string x)
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationChapter 14. Structures
Christian Jacob Chapter 14 Structures 14.1 Structures 14.1.1 Basic Definitions 14.1.2 Examples of Structures 14.1.3 Accessing Structure Members 14.1.4 Arrays of Structures 14.2 Structures and Pointers
More informationLecture 3. Variables. Variables
Lecture 3 Variables Variables Data processed by programs are input from keyboard by user, are read from the storage medium or are obtained by evaluating expressions. For this purpose it is necessary to
More informationA 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 informationDept. of Computer and Information Science (IDA) Linköpings universitet Sweden
Dept. of Computer and Information Science (IDA) Linköpings universitet Sweden Structures Unions Endianness Bit field Bit manipulation Collections of related variables (aggregates) under one name Can contain
More informationFundamentals 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 informationArrays. Systems Programming Concepts
Arrays Systems Programming Concepts Arrays Arrays Defining and Initializing Arrays Array Example Subscript Out-of-Range Example Passing Arrays to Functions Call by Reference Multiple-Subscripted Arrays
More informationadvanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef
today advanced data types (1) typedef. mon 23 sep 2002 homework #1 due today homework #2 out today quiz #1 next class 30-45 minutes long one page of notes topics: C advanced data types dynamic memory allocation
More informationLectures 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 informationCS201- Introduction to Programming Current Quizzes
CS201- Introduction to Programming Current Quizzes Q.1 char name [] = Hello World ; In the above statement, a memory of characters will be allocated 13 11 12 (Ans) Q.2 A function is a block of statements
More informationC++ C and C++ C++ fundamental types. C++ enumeration. To quote Bjarne Stroustrup: 5. Overloading Namespaces Classes
C++ C and C++ 5. Overloading Namespaces Classes Alastair R. Beresford University of Cambridge Lent Term 2007 To quote Bjarne Stroustrup: C++ is a general-purpose programming language with a bias towards
More informationEECS402 Lecture 24. Something New (Sort Of) Intro To Function Pointers
The University Of Michigan Lecture 24 Andrew M. Morgan Savicth: N/A Misc. Topics Something New (Sort Of) Consider the following line of code from a program I wrote: retval = oplist[whichop] (mainary, arysize);
More informationCS2141 Software Development using C/C++ C++ Basics
CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short
More informationProgramming for Engineers Structures, Unions
Programming for Engineers Structures, Unions ICEN 200 Spring 2017 Prof. Dola Saha 1 Structure Ø Collections of related variables under one name. Ø Variables of may be of different data types. Ø struct
More informationBasic Elements of C. Staff Incharge: S.Sasirekha
Basic Elements of C Staff Incharge: S.Sasirekha Basic Elements of C Character Set Identifiers & Keywords Constants Variables Data Types Declaration Expressions & Statements C Character Set Letters Uppercase
More informationCMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 13, SPRING 2013
CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 13, SPRING 2013 TOPICS TODAY Reminder: MIDTERM EXAM on THURSDAY Pointer Basics Pointers & Arrays Pointers & Strings Pointers & Structs
More information2. C99 standard guarantees uniqueness of characters for internal names. A. 12 B. 26 C. 31 D. 48
1. How can you make an infinite loop in C? A. while(1) { } B. loop:... goto loop; C. for(;;) { } D. All answers are right 2. C99 standard guarantees uniqueness of characters for internal names. A. 12 B.
More informationCS240: Programming in C
CS240: Programming in C Lecture 10: Review - Structures and Memory Allocation Unions Recap: Structures Holds multiple items as a unit Treated as scalar in C: can be returned from functions, passed to functions
More informationTypes and Structures
Types and Structures ECE2036 Lecture 8 CMPE102 Types and Structures Spring 2016 1 / 9 The Built-in Types 1 We have discussed in detail, and used the so called built-in types. These are variable types that
More informationBASIC ELEMENTS OF A COMPUTER PROGRAM
BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators
More informationData Type. structure. C Programming Lecture 11 : Structuret. struct union. typedef. A collection of one or more variables
Data Type C Programming Lecture 11 : Structuret struct union enum typedef structure t A collection of one or more variables possibly of different types, grouped together under a single name. ex) employee
More informationComputer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary
GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis
More informationCS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley.
CS61C Machine Structures Lecture 3 Introduction to the C Programming Language 1/23/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L03 Introduction to C (1) Administrivia
More informationCSCE 314 Programming Languages
CSCE 314 Programming Languages Haskell: Declaring Types and Classes Dr. Hyunyoung Lee 1 Outline Declaring Data Types Class and Instance Declarations 2 Defining New Types Three constructs for defining types:
More informationSWIFT - PROTOCOLS. Protocols also follow the similar syntax as that of classes, structures, and enumerations:
http://www.tutorialspoint.com/swift/swift_protocols.htm SWIFT - PROTOCOLS Copyright tutorialspoint.com Protocols provide a blueprint for Methods, properties and other requirements functionality. It is
More informationCSc Introduction to Computing
CSc 10200 Introduction to Computing Lecture 2 Edgardo Molina Fall 2011 - City College of New York Thursday, September 1, 2011 Introduction to C++ Modular program: A program consisting of interrelated segments
More informationStructures and Union. Fall Jinkyu Jeong GEBD029: Basis and Practice in Programming Fall 2014 Jinkyu Jeong
Structures and Union Fall 2014 Jinkyu Jeong (jinkyu@skku.edu) 1 Review Bitwise operations You need them for performance in terms of space and time Shifts are equivalent to arithmetics Enumeration you can
More informationQUIZ. 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 informationCOMPUTER APPLICATION
Total No. of Printed Pages 16 HS/XII/A.Sc.Com/CAP/14 2 0 1 4 COMPUTER APPLICATION ( Science / Arts / Commerce ) ( Theory ) Full Marks : 70 Time : 3 hours The figures in the margin indicate full marks for
More informationPresented By : Gaurav Juneja
Presented By : Gaurav Juneja Introduction C is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs of UNIX are written
More information3/22/2016. Pointer Basics. What is a pointer? C Language III. CMSC 313 Sections 01, 02. pointer = memory address + type
Pointer Basics What is a pointer? pointer = memory address + type C Language III CMSC 313 Sections 01, 02 A pointer can contain the memory address of any variable type A primitive (int, char, float) An
More informationChapter 6 part 1. Data Types. (updated based on 11th edition) ISBN
Chapter 6 part 1 Data Types (updated based on 11th edition) ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative
More informationVariables. 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 informationDEPARTMENT 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