Preview

Data Structure

Powerful Essays
Open Document
Open Document
15907 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Data Structure
Module 815

Data Structures Using C

M. Campbell

© 1993 Deakin University

Module 815

Data Structures Using C

Aim
After working through this module you should be able to create and use new and complex data types within C programs.

Learning objectives
After working through this module you should be able to: 1. Manipulate character strings in C programs. 2. Declare and manipulate single and multi-dimensional arrays of the C data types. 3. Create, manipulate and manage C pointers to data elements. 4. Create and manage complex data types in C. 5. Use unions to define alternate data sets for use in C programs. 6. Allocate memory to variables dynamically. 7. Manipulate characters and bits.

Content
Strings. Arrays. Pointers. Data definitions – Structures. Data definitions – Unions. Dynamic allocation of data Character and bit manipulation

Learning Strategy
Read the printed module and the assigned readings and complete the exercises as requested.

Assessment
Completion of exercises and the CML test at the end of the module.

Page 813-1

Module 815

Data Structures Using C

References & resources
The C Programming Language. 2nd. edition Brian W. Kernighan and Dennis M. Ritchie Prentice-Hall, 1988 Turbo C/C++ Manuals. Turbo C/C++ MS DOS compiler.

Page 813-2

Module 815 Objective 1

Data Structures Using C After working through this module you should be able to manipulate character strings in C programs

Strings
A string is a group of characters, usually letters of the alphabet. In order to format your printout in such a way that it looks nice, has meaningful titles and names, and is aesthetically pleasing to you and the people using the output of your program, you need the ability to output text data. We have used strings extensively already, without actually defining them. A complete definition of a string is ‘a sequence of char type data terminated by a NULL character,’. When C is going to use a string of data in some

You May Also Find These Documents Helpful

  • Satisfactory Essays

    In 1970 C programing was created by Dennis Richie and ken Thompson was made to create portability in UNIX…

    • 388 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Comp 220

    • 1463 Words
    • 6 Pages

    Pointers also have the requirement that the pointer type must be of the same data type as the variable, or the data that it points to or holds the address of. The power of pointers also hints at the potential complexity of their use, which is why this lab is focused almost entirely on several different aspects and uses of pointers. The lab also introduces pointer arrays and pointers to pointers.…

    • 1463 Words
    • 6 Pages
    Good Essays
  • Powerful Essays

    Visual Basic uses ________ values to represent characters such as A, B, and C in memory.…

    • 2759 Words
    • 44 Pages
    Powerful Essays
  • Powerful Essays

    It 210

    • 2960 Words
    • 12 Pages

    Although the value of a variable may change during execution of a program, in all our programs so far, a single value has been associated with each variable name at any given time. In this chapter, we will discuss the concept of an array—a collection of variables of the same type and referenced by the same name. We will discuss one-dimensional arrays (lists) at length and focus briefly on twodimensional arrays (tables). You will learn how to set up and use arrays to accomplish various tasks.…

    • 2960 Words
    • 12 Pages
    Powerful Essays
  • Good Essays

    Array Structure Proposal

    • 574 Words
    • 3 Pages

    Write a 2- to 3-page proposal describing the purpose of that structure and write the pseudocode for that structure.…

    • 574 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Lab_6_solution

    • 1259 Words
    • 3 Pages

    By the end of this lab session, you will be able to - declare an integer and character array - assign values to array during compilation and during execution - print contents of an array using repetition structure SAMPLE PROGRAM 1 /1. A program reads a series of numbers and print it reversed / include stdio.h void main (void) int i, Num, numbers10 printf(You may enter up to 10 integersn) printf(How many integers would you like to enter ) scanf (d, Num) if (Num 10) Num 10 printf(nEnter your numbers ) for (i 0 i Num i) scanf(d, numbersi) printf(nYour numbers reversed are ) for (i Num - 1 i 0 --i) printf(d , numbersi) printf(nn) SAMPLE PROGRAM 2 /2. Program that demonstrates the use of for loop to accept 8 numbers from user and displays certain numbers from the array / includestdio.h void main() int num, numbers8 printf(You need to enter 8 numbers ... n) for(num 0 num 7 num) scanf(i,numbersnum) printf(nn) printf(Your 1st element is dn,numbers0) printf(Your 2nd element is dn,numbers1) printf(Your 3rd element is dn,numbers2) printf(Your 8th element is dn,numbers7) printf(nn) printf(nnAll together your numbers aren) for(num 0 num 7 num) printf(d ,numbersnum) printf(nn) SAMPLE PROGRAM 3 /3. Program declares an array called charArray and assigns a single character to each of the array element using the initialize braces. Finally, the program prints the content of the array. / includestdio.h void main() char charArray8 F,r,i,e,n,d,s int i for(i 0 i 7 i) printf(charArrayd has a value of cn,i, charArrayi) printf(nMy favourite comedy sitcom is snn, charArray) SAMPLE PROGRAM 4 /4. Program consists of arrays (i.e. integer array and character array). It uses loops to sort the integer array elements in ascending and descending order. Then it displays the contents of the array elements respectively. / includestdio.h void main(void) int array10 0,1,2,3,4,5,6,7,8,9, i char string20 This is a string for(i…

    • 1259 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Task 1

    • 2644 Words
    • 8 Pages

    Procedural programming uses C programming language. C is considered to be a general purpose, work-horse language ideal for creating applications. Operating systems and interfacing with electronic control systems. It was made in 1972 by Dennis Ritchie at the Bell Telephone Laboratories. Unlike languages such as BASIC and PASCAL, C relies on symbols rather than keywords. As such, it is often described as being ‘terse’ and more difficult to learn, but typically offer more powerful solutions…

    • 2644 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    Data Structure

    • 328 Words
    • 2 Pages

    How do you create an instruction that steps through an array, performing an operation on each item?…

    • 328 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Data Structure

    • 785 Words
    • 4 Pages

    2. Write a test program that keeps the list of the following fruit items called fruitQ in the queue in the following order: Apple, Orange, Grapes, Cherry. Perform the following operations…

    • 785 Words
    • 4 Pages
    Satisfactory Essays
  • Powerful Essays

    Malloc

    • 3330 Words
    • 14 Pages

    In this assignment you will write a dynamic storage allocator for C programs, that is, your own…

    • 3330 Words
    • 14 Pages
    Powerful Essays
  • Powerful Essays

    The following information will introduce general knowledge in basic programming concepts. It shall discuss basic types of computer programming languages as-well-as program development. There are three basic types of computer programming languages that will be discussed in a simple and easy to understand manner. We shall also describe the program development cycle and discuss why it is important to use a structured and organized process to create a computer programming language.…

    • 1318 Words
    • 6 Pages
    Powerful Essays
  • Good Essays

    Kernel Data Structures

    • 3107 Words
    • 13 Pages

    As with any large software project, the Linux kernel provides these generic data structures and primitives to encourage code reuse. Kernel developers should use these data structures whenever possible and not “roll your own” solutions. In the following sections, we cover the most useful of these generic data structures, which are the following:…

    • 3107 Words
    • 13 Pages
    Good Essays
  • Good Essays

    C Programming Worksheet2

    • 1009 Words
    • 8 Pages

    A program is required to read a customer’s name, a purchase amount and a tax code. The tax…

    • 1009 Words
    • 8 Pages
    Good Essays
  • Good Essays

    C Programms

    • 1942 Words
    • 8 Pages

    1. Program to print text 2.Program To Read Two Numbers And Print The Sum Of Given Two Numbers. 3.Program To Accept Student Roll No, Marks in 3 Subjects and Calculate Total, Average and Print it. 4.Program To Read Three Numbers And Print The Biggest Of Given Three Numbers 5.Program To Read A Number And Find Whether The Given Number Is Even Or Odd. 6.Program to accept a year and check whether the given year IS leap year or not. 7.Individual Digits 8. Program to accept a three digit number and print the sum of individual digits. 9. Program to accept a number and check the given number is Armstrong or not. 10. Program to print ODD numbers from 1 to 10 11. Program to print natural numbers from 1 to 10 in Reverse 12. Program to print sum of the natural numbers from 1 to 10. 13. Program to accept a number and print mathematical table of the given no. 14. Program to print 1 to 10 mathematical tables . 15. Program to print fibonacci series . 16. Program to print numeric pyramid 17. Program to print numerical pyramid. 18. Program to print numerical diamond. 19. Program to print character pyramid. 20. Program to print character diamond. 21. Program to find biggest of two no by using ternary numbers 22. Program to find biggest of four no by using ternary numbers 23. Program to print smallest of four no by using ternary operators 24. Program to accept a year and check the given year is leap or not by using ternary 25. Program to accept a character in the uppercase and print in lower case. 26. Program to accept a character in any case and print in another case. 27. Program to natural number from 1 to 10 by using while loop. 28. Program to accept a string and print it by using the while loop. 29. Program to accept a string in upper case and print it by lower case. 30. Program to accept a string in any case and print it by another case . 31. Program to accept a string print each word in new line. 32. Program to accept a string and count no of capital letters, no. of…

    • 1942 Words
    • 8 Pages
    Good Essays
  • Powerful Essays

    memory layout

    • 3957 Words
    • 16 Pages

    A text segment , also known as a code segment or simply as text, is one of the sections of a program in an object file or in memory, which contains executable instructions.…

    • 3957 Words
    • 16 Pages
    Powerful Essays