Programming Techniques DT143G Lecture 1
20 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the correct file suffix for a C language program file?

  • .c (correct)
  • .txt
  • .cpp
  • .java
  • Which step follows the writing and saving of a C program?

  • Executing the program
  • Compiling the file (correct)
  • Linking the program
  • Debugging the code
  • Which of the following compilers automatically handles both compilation and linking in one command?

  • javac
  • cl
  • gcc (correct)
  • gpp
  • If the compilation of a C program is successful, what will it create?

    <p>Object file</p> Signup and view all the answers

    What is the purpose of a linker in C programming?

    <p>To link the program with other necessary files</p> Signup and view all the answers

    Which of the following correctly represents how to declare multiple integer variables in C?

    <p>int a, b, c;</p> Signup and view all the answers

    What is the purpose of the semicolon in a C program?

    <p>It signifies the end of a statement.</p> Signup and view all the answers

    What does the %d format specifier do in a printf statement?

    <p>Writes a decimal integer.</p> Signup and view all the answers

    In C programming, which statement is true regarding variable usage?

    <p>Each variable must have a type specified before use.</p> Signup and view all the answers

    Which of the following statements accurately describes the main function in a C program?

    <p>All programs must contain a function named 'main'.</p> Signup and view all the answers

    What is the purpose of including stdio.h in a C program?

    <p>It allows the use of input/output functions.</p> Signup and view all the answers

    In C programming, how are code statements grouped together?

    <p>By using curly braces.</p> Signup and view all the answers

    What is the purpose of a compiler in programming?

    <p>To translate a program into machine code.</p> Signup and view all the answers

    What is the primary characteristic of high-level programming languages?

    <p>They are closer to human language.</p> Signup and view all the answers

    Which statement about files in a computer is true?

    <p>Files can be organized into folders.</p> Signup and view all the answers

    How is data interpreted from a byte like 01000110?

    <p>It can be interpreted based on context.</p> Signup and view all the answers

    What is the role of a linker in program development?

    <p>To connect new programs with existing ones.</p> Signup and view all the answers

    In what form is a program executed by a computer?

    <p>In machine code (binary format).</p> Signup and view all the answers

    What does a bit represent in a computer system?

    <p>A binary state, either 0 or 1.</p> Signup and view all the answers

    Which of the following describes a program's structure?

    <p>A program is a sequence of instructions executed one by one.</p> Signup and view all the answers

    Study Notes

    Course Introduction

    • Course title: Programmeringsteknik DT143G
    • Lecture 1: Introduction
    • Course responsible: Pascal Rebreyend
    • Date: 4-11-2024
    • Location: Örebro University
    • Lectures: 15 lectures (2 * 45 minutes)
    • Labs: 6 lab sessions, 2 students per group
    • Lab software: Labs will be available on Blackboard soon.
    • Course materials: BB Learn
    • Course instructor office: T2232
    • Course instructor email: [email protected]
    • Number of assistants: 2

    Course Contents

    • Practical information
    • Organization of the course
    • First contact with programming
    • The spirit of the subject
    • Goals of the course

    Course Materials

    • Main textbook: C från Början by Jan Skansholm
    • References:
      • Programmeringsmetodik C by Gunnar Joki
      • The C programming Language by Brian W. Kernighan and Dennis M Ritchie
    • Other online materials available

    Lectures and Labs

    • Deadlines

    Criteria to Pass the Course

    • Approved written exam (some questions)
    • 50% of points: grade 3, 70-75% grade 4, 85-90% grade 5
    • Approved labs: Labs 3, 4, 5, and 6

    Computers and Programs

    • Computer components and functions are illustrated
    • Calculations are done
    • System diagram: Input/Output, CPU (Control Unit + Arithmetic Logic Unit (ALU)), Primary Memory (RAM, ROM), Secondary Memory (Hard Disk)

    Primary Memory

    • RAM (Random Access Memory): Stores data while the computer is running. Data is lost when the computer is switched off.
    • ROM (Read-Only Memory): Holds instructions/data programmed by the manufacturer. Cannot be altered by the user.

    Computers and Input-Output

    • Input Entity: Used to enter data (e.g., keyboard, mouse, sensors)
    • Output Entity: Used to display or output results (e.g., screen)

    Secondary Memory

    • Stores data when the computer is off.
    • Higher capacity than primary memory.
    • Slower than primary memory.

    Computers and Data

    • Data is stored in bits (0 or 1).
    • 8 bits = 1 byte
    • Conversions: Binary to decimal, decimal to hexadecimal
    • ASCII codes represent characters.

    Files

    • Data on the hard drive is in the form of files.
    • Each file is a sequence of bytes.
    • Files are identified by a name (e.g. myfile.exe, anotherfile.docx).
    • Folders (directories) are used to organize files.
    • Folders contain files and other folders

    Program

    • Instructions that tell the computer what to do.
    • Loaded into memory and executed one by one.
    • Each instruction has a set of bytes representing it.

    Programming Language

    • Computers understand machine code (0s and 1s).
    • Assembly language: one instruction per line.
    • High-level languages (e.g., C, C++, Java): Closer to human language, contain rules/syntax, and use concepts similar to each other .

    Developing a Program (Basic Way, C)

    • Write the program in a text editor.
    • Save it with the .c extension.
    • Compile the program to generate an object file (helloworld.o / helloworld.obj).
    • Link the object file with other programs to create the executable file (a.out (Linux) / helloworld.exe (Windows)).
    • Run the executable program.
    • Some languages are interpreted (translation line by line) vs compiled (into machine code).

    C Language

    • Developed by Dennis Ritchie in 1972.
    • High-level language, closely related to hardware.
    • Used to develop operating systems and embedded systems.
    • Powerful but demands careful programming.
    • Widely used language

    Example: Hello World

    • Code example* of a program that displays "Hello World" on the screen

    Programming in C

    • gcc (GNU Compiler Collection): Common compiler for C on Unix/Linux systems.
    • Usage: Compilation and linking are often combined into one command.
    • IDEs (Integrated Development Environments) exist but are not necessary to learn the language.

    Explanations

    • stdio.h file: Contains definitions for standard input/output functions.
    • Predefined functions such as printf are already defined.

    C Programming

    • Character to jump to next line: (e.g., \n).
    • Curly brackets: Group code statements into blocks (e.g., { code }).
    • Semicolons: End each C code statement (e.g., a=5;).
    • Whitespace (e.g., spaces, tabs): Ignored by the compiler.

    Variables

    • Programming involves computations on variables.
    • Variables: Allocated spaces in memory to store values
    • Variables must be declared with types (e.g., int, double, float, char).

    Variables in C

    • Variables must be declared before use.
    • Data types ( int, double, etc. ) must be specified when declaring variables

    A Simple Example

    • Example code showing how to declare and use an integer variable ('x').

    Conclusion

    • C is an important programming language.
    • Practice is necessary to become a proficient programmer.
    • Learn the program syntax.
    • Using software (gcc, emacs, Geany, Atom) for development
    • Programming is a skillset applicable across fields

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    This quiz covers the introduction to the Programming Techniques course DT143G, presented by Pascal Rebreyend. It includes details about the course structure, materials, and initial goals of programming. It is designed for students to familiarize themselves with the course landscape and expectations.

    More Like This

    Use Quizgecko on...
    Browser
    Browser