C is a high level language (HLL)

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

A C++ Crash Course Part II UW Association for Computing Machinery Questions & Feedback.
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Fundamentals of Computer and programming in C Programming Languages, Programs and Programming Rohit Khokher.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
C Programming Day 1 based upon Practical C Programming by Steve Oualline CS550 Operating Systems.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Primitive Variable types Basic types –char (single character or ASCII integer value) –int (integer) –short (not longer than int) –long (longer than int)
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
The little language that could Remember C is a “small language”
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
String Escape Sequences
C Programming. Chapter – 1 Introduction Study Book for one month – 25% Learning rate Use Compiler for one month – 60%
A simple C program: Printing a line of text #include main() { printf(“hello, world\n”); } Program output: hello, world.
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
The printf Method The printf method is another way to format output. It is based on the printf function of the C language. System.out.printf(,,,..., );
Computer Science 210 Computer Organization Introduction to C.
University of Calgary – CPSC 441. C PROGRAM  Collection of functions  One function “main()” is called by the operating system as the starting function.
Input & Output: Console
Chapter 11 Programming in C Compilation vs. Interpretation Different ways of translating high-level language Compilation translates code into machine.
1 計算機程式設計 Introduction to Computer Programming Lecture01: Introduction and Hello World 9/10/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
1 CSE1301 Computer Programming Lecture 5: Components of a C Program (Part 1) Linda M c Iver.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
1 Homework HW6 On line – due next class Starting K&R Chapter 7 and Appendix B Also, UNIX – Various chapters in Glass.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
 Integers and Characters  Character Strings  Input and Output.
Basic I/O in C Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens Stream Model of I/O header file: A stream provides a connection.
Matlab Data types, input and output. Data types Char: >> a = ‘ Jim ’ Char: >> a = ‘ Jim ’ Numeric: uint8, uint16, uint32, uint64 int8, int16, int32, int64.
A Quick Look at C for C++ Programmers Noah Mendelsohn Tufts University Web: COMP.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Introduction to C #include int main () { printf(“Welcome to CS 1621!\n”); }
Scott Marino MSMIS Kean University MSAS5104 Programming with Data Structures and Algorithms Week 1 Scott Marino.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
小型系統 心情 vs. 古典樂 心情 vs. 古典樂 浪漫求籤系統 美食導航系統 季潔亭雅鈺熒岱芸 美食導航系統 楊氏音樂模擬大會考人瑋 若維 芷萱 伽倩 楊氏音樂模擬大會考 麥當勞熱量計算系統 火星文困擾你嗎 ? 火星文困擾你嗎 ? 歌詞知多少 - 挑戰你的腦容量英琪 日馨 青雪 鈺娟.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
C++ Lesson 1.
Computer Science 210 Computer Organization
Introduction to C CSE 2031 Fall /3/ :33 AM.
C Short Overview Lembit Jürimägi.
C Basics.
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.
Programming in C Input / Output.
Input and Output Lecture 4.
Computer Science 210 Computer Organization
Introduction to the C Language
Chapter 11 Introduction to Programming in C
פרטים נוספים בסילבוס של הקורס
Chapter 11 Introduction to Programming in C
Introduction to C Topics Compilation Using the gcc Compiler
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
Chapter 11 Introduction to Programming in C
C Programming Getting started Variables Basic C operators Conditionals
Introduction to C Topics Compilation Using the gcc Compiler
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Chapter 11 Programming in C
Introduction to C EECS May 2019.
Generalities for Assembly Language
Introduction to C CSE 2031 Fall /15/2019 8:26 AM.
Chapter 11 Introduction to Programming in C
Introduction to C CS 3410.
Presentation transcript:

C is a high level language (HLL) Its syntax is much the same as Java and C++, but no objects. Actually, C++ and Java are much the same as C. C was designed in the 1970s.

Java

C

Why C ? Millions of lines of code have been written, so you are going to run into it. One place you are likely to run into it are the UW-Madison 500-level CS systems classes. It gives a common language to reference, so the remainder of 354 can base examples on C code (not Java, C++, Ruby, Python, etc.). Any C++ programmer also needs to know C.

Comments in C code /* my comment */ comments may span lines opening delimiter closing delimiter

/* hello world program */ #include <stdio.h> main() { printf("hello, world\n"); }

C’s printf() is like: Java’s System.out.print() or C++’s cout

Java source code compiler Java “byte codes” Java interpreter (JVM)

high level language source code compiler assembly language source code assembler machine code linking and loading execution

high level language source code C preprocessor C compiler assembly language source code

the C preprocessor does 1. #include 2 the C preprocessor does 1. #include 2. macro substitution for example: #define MAX 100 3. conditional compilation

#include <stdio.h> #include "myheaders.h" 1.

#include <stdio.h> 2. #define MAX 100 main() { int x; x = 1; while (x <= MAX) { printf("%d\n", x); x++; }

C's basic types char – An ASCII character. Typically 1 byte. int – A 2's complement integer. Typically the size of a word on the architecture. float – An IEEE single precision floating point value. 32 bits. double – An IEEE double precision floating point value. 64 bits Not listed here: pointer types.

Type qualifiers If and when you believe you need to use these, look them up: signed unsigned – causes integer arithmetic operations to be ones for unsigned integers long – relates to size short – relates to size const – do not use this qualifier to define a constant. What happens when code tries to change a variable declared as const is implementation dependent.

C string An array of characters, which uses the null character to delimit the end of the string. '\0' is the null character. All zeros bit pattern in ASCII. "Hi." "12"

I/O Concept and Implementation Logical places where input comes from and output goes to: stdin stdout stderr

int printf(char *format [, arg1] … ); Output (in the stdio library) int printf(char *format [, arg1] … ); function name string, called the format string optional, as referenced by string return value: # characters printed

printf("howdy"); howdy ^ A better way to do this (for security reasons) is puts("howdy");

Within the format string, to reference variable (values): %d for an integer %u for unsigned %c for a character %s for a string Each %character references an argument

3 + 5= 8 int x, y; x = 3; y = 5; printf(" = %d\n", x, y, x + y); %d + newline character 3 + 5= 8 ^

#include <stdio.h> main() { int x; x = 354; printf("[%d]\n", x); } OUTPUT [354] [ 354] [354 ] Optional field width

#include <stdio.h> main() { float x; x = 1234.5678; printf("[%f]\n", x); printf("[%1f]\n", x); printf("[%2f]\n", x); printf("[%20f]\n", x); printf("[%-20f]\n", x); printf("[%1.2f]\n", x); printf("[%-2.3f]\n", x); printf("[%-20.3f]\n", x); } OUTPUT [1234.567749] [ 1234.567749] [1234.567749 ] [1234.57] [1234.568] [1234.568 ]