Programming Fundamental-1

Slides:



Advertisements
Similar presentations
This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Advertisements

Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
Introduction to C++ September 12, Today’s Agenda Quick Review Check your programs from yesterday Another Simple Program: Adding Two Numbers Rules.
1 Objectives Understand streamed input and output.
What Data Do We Have? Sections 2.2, 2.5 August 29, 2008.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
Input/Output Main Memory istream ostream Disk Drive Keyboard Scanner Disk Drive Monitor Printer stream = sequence of bytes.
CS1061 C Programming Lecture 5: Building Blocks of Simple Programs A. O’Riordan, 2004.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Input and Output in Console Mode UNIVERSITY OF THE PUNJAB (GUJRANWALA CAMPUS) ADNAN BABAR MT14028 CR
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Week 1 Algorithmization and Programming Languages.
CHAPTER 7 DATA INPUT OUTPUT Prepared by: Lec. Ghader R. Kurdi.
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
"Give a person a fish and you feed them for a day; teach that person to use the Internet and they won't bother you for weeks.“ --unknown "Treat your password.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
Programming Fundamentals
Introduction to Programming Lecture 4. Key Words of C main main if if else else while while do do for for.
CHAPTER 2 PART #3 C++ INPUT / OUTPUT 1 st Semester King Saud University College of Applied studies and Community Service CSC1101 By: Fatimah.
Chapter 3 – Variables and Arithmetic Operations. First Program – volume of a box /************************************************************/ /* Program.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Review. Problem 1 What is the output of the following piece of code void increment(int x) { x++; } int main() { int y = 10; increment(y); cout
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
Lecture 4 Computer Programming // sample C++ program #include using namespace std; int main() { cout
© by Pearson Education, Inc. All Rights Reserved.
Topic Pre-processor cout To output a message.
What Actions Do We Have Part 1
Introduction to C++ Programming
Chapter 2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
Programming Fundamental
CPS120: Introduction to Computer Science
CPS120: Introduction to Computer Science
Computing Fundamentals
BASIC ELEMENTS OF A COMPUTER PROGRAM
Introduction to C++ October 2, 2017.
C++ Arrays.
Chapter 2 part #3 C++ Input / Output
OUTPUT STATEMENTS GC 201.
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
Introduction to C++ Programming
Programming Funamental slides
Counting Loops.
Programming Funamental slides
الوحدة الرابعة البرمجة وصياغة حل المسائل البرمجة وأهميتها أهداف الدرس الأول مفهوم البرمجة. الفرق بين المبرمج ومستخدم البرنامج. الحاجة إلى البرامج.
Course websites CS201 page link at my website: Lecture slides
“If you can’t write it down in English, you can’t code it.”
Intro to Programming Week # 2 Variables/Data type Lecture # 4 & 5
Introduction to C++ Programming
CS150 Introduction to Computer Science 1
Chapter 4 INPUT AND OUTPUT OBJECTS
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Arithmetic Operations
Fundamental Programming
What Actions Do We Have Part 1
EECE.2160 ECE Application Programming
Chapter 2 part #3 C++ Input / Output
Introduction to Programming
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
EECE.2160 ECE Application Programming
Chapter 1 c++ structure C++ Input / Output
getline() function with companion ignore()
Programming Fundamental-1
Presentation transcript:

Programming Fundamental-1 Instructor Name: Muhammad Safyan Lecture-3

Cout<< (Statement) cout << x; cout << x + x; cout << "x="; cout << "x = " << x; cout << x + y << " = " << y + x; // cout << "x + y = " << x + y;

Cin>> (Statement) known as input stream in C++. cin takes data from keyboard and sends it to the memory variable. For the moment it is a screen of the monitor . cin >> x; cin >> x >> y;

Escape Sequence Character Notes: Escape Sequence Character Escape Sequence are Non-printable and control characters to control the output, represented by a so-called escape sequence, which begins with a back-slash (\) Escape Sequence Description \n New-line (or Line-feed) \r Carriage-return \t Tab \" Double-quote (needed to include " in double-quoted string) \' Single-quote \\ Back-slash (to resolve ambiguity) \b backspace Cout<<“\n”; Cout<<x<<“\n”<<y;

Escape Sequence Character Notes: Escape Sequence Character Cout<<“\n”; Cout<<x<<“\n”<<y; Endl (end of line) cout << "*\n**\n***\n****\n*****" << endl;

Quadratic Equation In algebra In C y = ax2 + bx + c y = a*x*x + b*x + c

Discriminant b2 - 4ac 2a = b*b - 4*a*c /2 *a Incorrect answer Solution = (b*b - 4*a*c) /(2 *a) Correct answer

Interesting Problem Given a four-digit integer, separate and print the digits on the screen

Analysis Number = 1234 Take the remainder of the above number after dividing by 10 Eg 1234 / 10 gives remainder 4 1234 % 10 = 4 Remove last digit 1234/10 = 123.4 123 (Truncation due to Integer Division) 123 %10 gives 3 123/10 = 12.3 12 (Truncation due to Integer Division) 12 % 10 gives remainder 2 12/10 = 1.2 1 (Truncation due to Integer Division) Final digit remains

Code #include <iostream.h> main ( ) { int number; int digit; cout << “Please enter a 4 digit integer : ”; cin >> number; digit = number %10; cout <<“The digit is: “ << digit << ‘\n’; // first digit; and then << ‘\n’ number = number / 10; digit = number % 10; cout <<“The digit is: “ << digit << ‘\n’; cout <<“The digit is: “ << digit; } write a program that takes radius of a circle from the user and calculates the diameter, ircumference and area of the circle and display the resul