1.3 Console Input And Output academy.zariba.com 1.

Slides:



Advertisements
Similar presentations
Execute Blocks of Code Multiple Times Telerik Software Academy C# Fundamentals – Part 1.
Advertisements

Mathematics for Computing Lecture 4: Algorithms and flowcharts Dr Andrew Purkiss-Trew Cancer Research UK
1 CSE1301 Computer Programming Lecture 5: Components of a C Program (Part 1)
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
1.9 Methods academy.zariba.com 1. Lecture Content 1.What is a method? Why use methods? 2.Void Methods and methods with parameters 3.Methods which return.
Basic Input/Output and Variables Ethan Cerami New York
1.10 Strings academy.zariba.com 1. Lecture Content 1.What is a string? 2.Creating and Using strings 3.Manipulating Strings 4.Other String Operations 5.Building.
1.7 Arrays academy.zariba.com 1. Lecture Content 1.Basic Operations with Arrays 2.Console Input & Output of Arrays 3.Iterating Over Arrays 4.List 5.Cloning.
Input and Output in Console Mode UNIVERSITY OF THE PUNJAB (GUJRANWALA CAMPUS) ADNAN BABAR MT14028 CR
Simple Data Type Representation and conversion of numbers
Reading and Writing to the Console Svetlin Nakov Telerik Corporation
 Pearson Education, Inc. All rights reserved Formatted Output.
1 2 2 Introduction to Java Applications Introduction Java application programming –Display messages –Obtain information from the user –Arithmetic.
Munster Programming Training
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
HPC 1.4 Notes Learning Targets: - Solve equations using your calculator -Solve linear equations -Solve quadratic equations - Solve radical equations -
1.6 Loops academy.zariba.com 1. Lecture Content 1.While loops 2.Do-While loops 3.For loops 4.Foreach loops 5.Loop operators – break, continue 6.Nested.
Chapter 2: Using Data.
The Quadratic Formula. What does the Quadratic Formula Do ? The Quadratic formula allows you to find the roots of a quadratic equation (if they exist)
Type Conversions Implicit Conversion Explicit Conversion.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Reading and Writing to the Console Svetlin Nakov Telerik Corporation
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
COMP 171: Data Types John Barr. Review - What is Computer Science? Problem Solving  Recognizing Patterns  If you can find a pattern in the way you solve.
1.5 Conditional Statements academy.zariba.com 1. Lecture Content 1.If-else statements 2.If-else-if statements 3.Switch-case statements 2.
solve x + (-16) = -12 solve x + (-16) = X = 4.
5.3 – Solving Quadratic Equations by Factoring. Ex. 1 Solve y = x 2 + 5x + 6 by factoring.
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
ITEC 109 Lecture 7 Operations. Review Variables / Methods Functions Assignments –Purpose? –What provides the data? –What stores the data? –What type of.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Quadratic Relations Solving Quadratic Equations Day 3: Solve by Factoring Tuesday, January 05, 20161Day 2 - Solve by Factoring.
Quadratic Equations. PROGRAM QuadraticEquations_1 IMPLICIT NONE REAL A, B, C, Discriminant, Root_1, Root_2 ! Get the coefficients PRINT *, "Enter the.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
Console Input / Output Reading and Writing to the Console SoftUni Team Technical Trainers Software University
1.2 Primitive Data Types and Variables
CMPS 1371 Introduction to Computing for Engineers CHARACTER STRINGS.
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
Lecture 5: Expressions and Interactivity Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
C# Programming: Basic Concept Part 2 Computer and Programming (204111)
Solve by taking roots. Warm up. Homework Review Completing the Square.
1.8 Multidimensional Arrays academy.zariba.com 1.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
2.3 Output Formatting. Outputting Format Specify the number of spaces, “c”, used to print an integer value with specifier %cd, e.g., %3d, %4d. E.g. printf.
CSCI 125 & 161 / ENGR 144 Lecture 6 Martin van Bommel.
Solving Quadratic Equations by Graphing  Quadratic Equation- A quadratic function set equal to a value, in the form ax 2 +bx+c, where a≠0  Standard.
C# Basic Syntax, Visual Studio, Console Input / Output
Arithmetic operations and operators, converting data types and formatting programs for output. Year 11 Information Technology.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Using the Console.
Do Now – Take out your homework. Take You have 5 minutes.
C++ Basic Syntax – Homework Exercises
TMF1414 Introduction to Programming
2.2 Defining Classes Part 2 academy.zariba.com.
Chapter 3 Java Input/Output.
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
The Quadratic Formula.
Variables, Loops, Decision Statements, etc
VB.Net Programming Console Application
Chapter 3 Input/Output.
Suppose I want to add all the even integers from 1 to 100 (inclusive)
9.2 Solving Quadratic Equations using square roots
Introduction to Java Applications
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
Text Copyright (c) 2017 by Dr. E. Horvath
DATA TYPES AND OPERATIONS
CS 1111 Introduction to Programming Spring 2019
Programming Fundamental-1
Write Quadratic Functions and Models
Presentation transcript:

1.3 Console Input And Output academy.zariba.com 1

Lecture Content 1.Printing on the Console 2.Reading from the Console 2

1. Printing on the Console Printing numbers. Printing more variables using formatting strings. 3

Formatting Strings 4 The formatting string looks like this: {placeholder index[,alignment][:formatString]} e.g. {0,20:F3} There are different types of formatStrings: “0.00” - floating C - currency D – decimal E – exponential (scientific) F – fixed point G – general N - number P - percentage R – round Trip X - hexadecimal

2. Reading from the Console Reading a character. Reading a line. Reading keys. 5

Console.Read(); Reads a single character from the console, after pressing enter. Returns an integer. To obtain a character we need to perform a type casting. 6

Console.ReadKey(); Reads a combination of keys from the keyboard. The result is of type ConsoleKeyInfo. KeyChar – holds the key entered Modifiers – holds the modifiers information, e.g. ctrl 7

Console.ReadLine(); Reads a single line of characters. The result is of type string. To read integers we need to convert (parse) the string to an integer value. 8

Homework 9 1. Write a program that reads two positive integer numbers and prints how many numbers p exist between them such that the reminder of the division with p by 5 is 0 (inclusive). Example: p(17,25) = 2 if 2. Write a program that gets two numbers from the console and prints the greater of them. Don’t use if statements. 3.Write a program that reads the coefficients a, b and c of a quadratic equation ax 2 +bx+c=0 and solves it (prints its real roots). 4.Write a program that gets a number n and after that gets more n numbers and calculates and prints their sum. 5.Write a program that reads an integer number n from the console and prints all the numbers in the interval [1..n], each on a single line.

10 References

11 Zariba Academy Questions