Revision.

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

A simple C++ program /* * This program prints the phrase "Hello world!" * on the screen */ #include using namespace std; int main () { cout
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
STRING Dong-Chul Kim BioMeCIS UTA 10/7/
C Tokens Identifiers Keywords Constants Operators Special symbols.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
Type Conversions Implicit Conversion Explicit Conversion.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
Lecture 3: The parts of a C++ program (Cont’d) Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
CECS 130 EXAM 1. To declare a constant (read only) value: const int x = 20; const float PI = 3.14; Can we do this? const int x;
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
Functions. What is a function? It’s a group of statements that has a specific purpose and can be be repeatedly executed as needed. By using functions:
C is a high level language (HLL)
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Numbers in ‘C’ Two general categories: Integers Floats
CSCE 206 Structured Programming in C
UNIT 5 C Pointers.
Arrays Declarations CSCI N305
CSE1320 Loop Dr. Sajib Datta
Array 9/8/2018.
Pointers.
Hassan Khosravi / Geoffrey Tien
C++ Arrays.
By: Syed Shahrukh Haider
Introduction to C Programming
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.
Pointers.
Input and Output Lecture 4.
CSI 121 Structured Programming Language Lecture 7: Input/Output
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Chapter 6 - Arrays Outline 6.1 Introduction 6.2 Arrays
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
CSCE 206 Lab Structured Programming in C
Arrays Chapter 8 Copyright © 2008 W. W. Norton & Company.
CSC215 Homework Homework 04 Due date: Oct 14, 2016.
CS111 Computer Programming
Arrays Outline Introduction Arrays Declaring Arrays
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
Introduction to C Topics Compilation Using the gcc Compiler
Structures vol2.
UMBC CMSC 104 – Section 01, Fall 2016
Qsort.
Pointers.
Programs and Classes A program is made up from classes
Files.
Conversion Check your class notes and given examples at class.
Java Programming Review 1
Functions.
WEEK-2.
Introduction to C Topics Compilation Using the gcc Compiler
String manipulation string.h library
INC 161 , CPE 100 Computer Programming
Functions continued.
Pointers Chapter 11 Copyright © 2008 W. W. Norton & Company.
Loops.
Fundamental Programming
Homework Finishing Chapter 2 of K&R. We will go through Chapter 3 very quickly. Not a lot is new. Questions?
Let’s start from the beginning
Arrays.
Arrays.
Pointers Chapter 11 Copyright © 2008 W. W. Norton & Company.
Chapter 11 Programming in C
CSCE 206 Lab Structured Programming in C
DATA TYPES There are four basic data types associated with variables:
Course Outcomes of Programming In C (PIC) (17212, C203):
Revision.
Expressions An Expression is a sequence of operands and operators that reduces to a single value. An operator is a language-specific syntactical token.
Presentation transcript:

Revision

Your programs should generally.. Have plenty of comments Be uniform in style Have good structure Be simple, not bloated Be universal (cover corner cases) Be modular (easily reusable) Effective (optimal algorithms) Easily readable 2018 Risto Heinsar

Basic data types Data type Format Size Integers int %d 2 or 4 bytes short %h 2 bytes unsigned %u Characters char %c 1 byte char[] %s ? byte(s) Floating point float %f 4 bytes double %lg 8 bytes 2018 Risto Heinsar

Loops while do while for i = 0; while (i < 10) { printf("%d\n", i); i++; } i = 0; do { printf("%d\n", i); i++; } while ( i < 10); for (i = 0; i < 10; i++) { printf("%d\n", i); } 2018 Risto Heinsar

Functions and programm structure #include <stdio.h>   void PrintDigit(int value); // function prototype int main(void) //main() function with return type { int digit; scanf("%d", &digit); PrintDigit(digit); // function call return 0; // return value from main function } void PrintDigit(int value) printf("Number read was: %d\n", value); 2018 Risto Heinsar

Revision task 1 Initialize a string of Your choosing Remove all of the vowels from that string. The resulting string must be written in a different variable, original must stay intact! Output both the original and the modified string on the screen. Create at least one function besides main in a meaningful way 2018 Risto Heinsar

Revision task 2 (use our code template) The data is mixed type (both metric and imperial), stored in a single array. You can think of it as distance travelled by office workers during work hours in an international setting. One line per employee. The second column of the array defines the units – 0 for metric, 1 for imperial. Data units are either meters or feet. The output must be only given in metric units. Output the distance walked by every employee Output the following statistics: average distance walked, total distance walked Create at least three functions besides main in a meaningful way 1 foot = 0.3048 meters 2018 Risto Heinsar

Revision task 3 Read N digits in between 0 ≤ ai ≤ 9 Find the frequency for each of the digits (rate of occurrence) Output the digits with their frequencies E.g. Number 0 occurred 1 time Number 1 occurred 12 times … Number 9 occurred 9 times Output the basic statistics: Lowest and highest number entered, most common number(s) Create at least three functions besides main in a meaningful way, one of which must return a non-void value 2018 Risto Heinsar