This document provides an overview of the C programming language and tools that will be used in a C programming course. It introduces C syntax including variables, input/output, and conditional statements. The key topics covered are:
1. The C language was created in 1972 for systems programming and has since been standardized.
2. The tools that will be used are Notepad++ for editing, Filezilla for file transfer, the Panther server for compilation, and Putty for connecting to Panther.
3. Basic C syntax is demonstrated including variables, input/output functions, and if/else conditional statements.
Survey of programming language getting started in Cummeafruz
油
This document provides an overview of C programming concepts covered in the first lecture of a C programming course, including:
- The history and uses of C as a systems programming language.
- Key components of a C program like variables, input/output functions, and conditional statements.
- Tools used like Notepad++, Filezilla, and the Panther compiler.
- Basic data types in C like int, float, char and how to declare constants.
- Formatting output with printf and reading input with scanf.
- How to write simple programs that take user input, perform calculations, and display output using concepts like variables, conditionals, and standard I/O functions
This document provides an overview of key concepts in the C programming language that will be covered in CSC 270 - Survey of Programming Languages. It introduces C syntax, tools, program structure, variables, input/output, and decisions using if/else statements. It also compares C to other languages like C++, Java, and highlights C's origins and use for systems programming. The document contains code examples and discusses basic data types, constants, operators, and formatting output.
This document provides an overview of key concepts in the C programming language that will be covered in CSC 270 - Survey of Programming Languages. It introduces C basics like program structure, variables, input/output, and conditional statements. It also compares C to other languages like C++, Java, and discusses C standardization over time. The document includes examples of simple C programs and explanations of core C concepts.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
油
The document provides an overview of the C programming language. It begins by explaining that Objective-C extends standard ANSI C with object-oriented capabilities. It then discusses why C remains important today due to its use in libraries, operating systems, and as the base for many other popular languages. The document proceeds to cover basic C concepts like variables, data types, functions, flow control, pointers, memory allocation, and I/O parameters. It emphasizes that C provides high performance with a minimal footprint while abstracting away the CPU and memory.
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyGrejoJoby1
油
The slides from the C++ and OOPS Crash Course conducted for ACM DBIT by Grejo Joby.
Learn the concepts of OOPS and C++ Programming in the shortest time with these notes.
This document provides an overview of a C++ programming course. It introduces fundamental C++ concepts like data types, variables, input/output statements, and arithmetic, relational, and logical operators. It also presents some simple example programs to calculate the mean of input numbers to demonstrate basic programming constructs like comments, functions, and conditional statements.
I prepared these slides for the student of FSC BSC BS Computer science.these slides are very easily understanding the concept of programming in C++.All topics are clear with the help of examples easy in reading the topic and understanding the logic.
This document provides an introduction to programming with C++, including comments, data types, variables, arithmetic operators, and expressions. It discusses single-line and multi-line comments to document code. The fundamental C++ data types are integer, floating point, and character, each with different size ranges. Variables are declared with a data type and assigned values. Arithmetic operators allow mathematical expressions to be evaluated using precedence rules. Relational operators enable boolean expressions.
This document provides an overview of an intermediate computer programming course at the University of Gondar in Ethiopia. The course code is CoEng2111 and it is taught by instructor Wondimu B. Topics that will be covered in the course include C++ basics, arrays, strings, functions, and recursion. The course materials are presented over several pages that define concepts, provide code examples, and explain key ideas like variables, data types, operators, and array implementation in C++.
02 functions, variables, basic input and output of c++Manzoor ALam
油
This document discusses computer programming functions, variables, and basic input/output in C and C++. It covers:
- Defining and calling functions, function parameters and return values.
- Declaring and assigning values to variables of different data types like int, float, and double.
- Using basic input/output functions like cout and cin to display output and get user input.
- The scope of variables and how they work within and outside of functions.
This document provides an overview of the C programming language by comparing it to other languages like Java. It discusses key features of C like data types, variables, input/output, decisions with if/else statements, loops, functions, constants, and libraries. The document also compares C and Java highlighting similarities and differences in their syntax, compilation process, memory management, and other features. It aims to introduce programmers to the basic concepts of C.
The document provides an introduction to C programming, covering topics such as what a program is, programming languages, the history of C, and the development stages of a C program. It discusses the key components of a C program including preprocessing directives, the main function, and program layout. Examples are provided to illustrate C code structure and the use of variables, keywords, operators, input/output functions, and formatting output with printf.
The document discusses an introduction to C++ programming. It covers basic C++ concepts like variables, data types, input/output, operators, and functions. It provides examples of simple C++ programs and explains concepts like object-oriented programming, classes, and inheritance. The document is meant to introduce students to C++ as their first object-oriented programming language.
Lec2_cont.pptx galgotias University questionsYashJain47002
油
This document discusses key concepts in Python including variables, data types, expressions, and statements. It covers defining variables and constants, using operators in expressions, and handling different data types. Comments are introduced as a way to document code. Examples demonstrate taking user input, performing calculations, and displaying output. Mnemonic variable names are recommended to improve readability.
This document provides an introduction to basic elements of C++ programming, including:
- The structure of a basic C++ program with an example main function.
- Common data types like integers, floating point numbers, characters, and strings.
- Arithmetic operators and precedence.
- Expressions, input/output, and type casting.
- Variables, memory allocation, and initializing variables.
- Control structures like increment/decrement operators.
- Program style guidelines including comments and formatting.
Code optimization techniques aim to improve the efficiency of code without changing its output. Some key techniques include:
- Using appropriate variable types like unsigned integers to improve performance.
- Avoiding global variables which prevent register allocation and introduce overhead.
- Optimizing control structures like replacing if-else with switch.
- Loop optimizations like unrolling small loops, combining nested loops, and early termination.
- Function optimizations like putting loops inside functions and minimizing parameter passing.
- Other techniques like code motion to move invariant code out of loops.
The document discusses various code optimization techniques that can be used to improve the efficiency of a program without changing its functionality. It covers techniques like using appropriate data types, avoiding global variables, using arrays instead of switch-case statements, combining loops, putting loops inside functions, and early termination of loops. Optimizing variables, control structures, functions and loops can help reduce memory usage and improve execution speed of a program.
I am Jayson L. I am a C++ Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from The University of Sheffield, UK. I have been helping students with their homework for the past 8 years. I solve homework related to C++.
Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Homework.
C is a structured programming language developed by Dennis Ritchie. It supports functions and modularity through header files and libraries. C programs are compiled into executable files. Key features include variables, data types, operators, conditional statements, loops, arrays, structures, pointers, and functions. Functions can be called by value where changes are local, or by reference where changes affect the original variable.
Lecture#2 Computer languages computer system and Programming EC-105NUST Stuff
油
The document discusses three types of computer languages: machine language, assembly language, and high-level languages. Machine language is directly understood by computers using binary, while assembly language uses abbreviations and high-level languages resemble English. It also introduces C++ programming concepts like variables, data types, input/output streams, arithmetic operators, and conditional statements. Sample programs are provided to demonstrate printing text, getting user input, performing calculations, and making decisions.
Python is a general purpose programming language that can be used for both programming and scripting. It is an interpreted language, meaning code is executed line by line by the Python interpreter. Python code is written in plain text files with a .py extension. Key features of Python include being object-oriented, using indentation for code blocks rather than brackets, and having a large standard library. Python code can be used for tasks like system scripting, web development, data analysis, and more.
This document provides an overview of a C++ programming course. It introduces fundamental C++ concepts like data types, variables, input/output statements, and arithmetic, relational, and logical operators. It also presents some simple example programs to calculate the mean of input numbers to demonstrate basic programming constructs like comments, functions, and conditional statements.
I prepared these slides for the student of FSC BSC BS Computer science.these slides are very easily understanding the concept of programming in C++.All topics are clear with the help of examples easy in reading the topic and understanding the logic.
This document provides an introduction to programming with C++, including comments, data types, variables, arithmetic operators, and expressions. It discusses single-line and multi-line comments to document code. The fundamental C++ data types are integer, floating point, and character, each with different size ranges. Variables are declared with a data type and assigned values. Arithmetic operators allow mathematical expressions to be evaluated using precedence rules. Relational operators enable boolean expressions.
This document provides an overview of an intermediate computer programming course at the University of Gondar in Ethiopia. The course code is CoEng2111 and it is taught by instructor Wondimu B. Topics that will be covered in the course include C++ basics, arrays, strings, functions, and recursion. The course materials are presented over several pages that define concepts, provide code examples, and explain key ideas like variables, data types, operators, and array implementation in C++.
02 functions, variables, basic input and output of c++Manzoor ALam
油
This document discusses computer programming functions, variables, and basic input/output in C and C++. It covers:
- Defining and calling functions, function parameters and return values.
- Declaring and assigning values to variables of different data types like int, float, and double.
- Using basic input/output functions like cout and cin to display output and get user input.
- The scope of variables and how they work within and outside of functions.
This document provides an overview of the C programming language by comparing it to other languages like Java. It discusses key features of C like data types, variables, input/output, decisions with if/else statements, loops, functions, constants, and libraries. The document also compares C and Java highlighting similarities and differences in their syntax, compilation process, memory management, and other features. It aims to introduce programmers to the basic concepts of C.
The document provides an introduction to C programming, covering topics such as what a program is, programming languages, the history of C, and the development stages of a C program. It discusses the key components of a C program including preprocessing directives, the main function, and program layout. Examples are provided to illustrate C code structure and the use of variables, keywords, operators, input/output functions, and formatting output with printf.
The document discusses an introduction to C++ programming. It covers basic C++ concepts like variables, data types, input/output, operators, and functions. It provides examples of simple C++ programs and explains concepts like object-oriented programming, classes, and inheritance. The document is meant to introduce students to C++ as their first object-oriented programming language.
Lec2_cont.pptx galgotias University questionsYashJain47002
油
This document discusses key concepts in Python including variables, data types, expressions, and statements. It covers defining variables and constants, using operators in expressions, and handling different data types. Comments are introduced as a way to document code. Examples demonstrate taking user input, performing calculations, and displaying output. Mnemonic variable names are recommended to improve readability.
This document provides an introduction to basic elements of C++ programming, including:
- The structure of a basic C++ program with an example main function.
- Common data types like integers, floating point numbers, characters, and strings.
- Arithmetic operators and precedence.
- Expressions, input/output, and type casting.
- Variables, memory allocation, and initializing variables.
- Control structures like increment/decrement operators.
- Program style guidelines including comments and formatting.
Code optimization techniques aim to improve the efficiency of code without changing its output. Some key techniques include:
- Using appropriate variable types like unsigned integers to improve performance.
- Avoiding global variables which prevent register allocation and introduce overhead.
- Optimizing control structures like replacing if-else with switch.
- Loop optimizations like unrolling small loops, combining nested loops, and early termination.
- Function optimizations like putting loops inside functions and minimizing parameter passing.
- Other techniques like code motion to move invariant code out of loops.
The document discusses various code optimization techniques that can be used to improve the efficiency of a program without changing its functionality. It covers techniques like using appropriate data types, avoiding global variables, using arrays instead of switch-case statements, combining loops, putting loops inside functions, and early termination of loops. Optimizing variables, control structures, functions and loops can help reduce memory usage and improve execution speed of a program.
I am Jayson L. I am a C++ Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from The University of Sheffield, UK. I have been helping students with their homework for the past 8 years. I solve homework related to C++.
Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Homework.
C is a structured programming language developed by Dennis Ritchie. It supports functions and modularity through header files and libraries. C programs are compiled into executable files. Key features include variables, data types, operators, conditional statements, loops, arrays, structures, pointers, and functions. Functions can be called by value where changes are local, or by reference where changes affect the original variable.
Lecture#2 Computer languages computer system and Programming EC-105NUST Stuff
油
The document discusses three types of computer languages: machine language, assembly language, and high-level languages. Machine language is directly understood by computers using binary, while assembly language uses abbreviations and high-level languages resemble English. It also introduces C++ programming concepts like variables, data types, input/output streams, arithmetic operators, and conditional statements. Sample programs are provided to demonstrate printing text, getting user input, performing calculations, and making decisions.
Python is a general purpose programming language that can be used for both programming and scripting. It is an interpreted language, meaning code is executed line by line by the Python interpreter. Python code is written in plain text files with a .py extension. Key features of Python include being object-oriented, using indentation for code blocks rather than brackets, and having a large standard library. Python code can be used for tasks like system scripting, web development, data analysis, and more.
Anorectal malformations refer to a range of congenital anomalies that involve the anus, rectum, and sometimes the urinary and genital organs. They result from abnormal development during the embryonic stage, leading to incomplete or absent formation of the rectum, anus, or both.
Digital Electronics: Fundamentals of Combinational CircuitsGS Virdi
油
An in-depth exploration of combinational logic circuit design presented by Dr. G.S. Virdi, former Chief Scientist at CSIR-Central Electronics Engineering Research Institute, Pilani, India. This comprehensive lecture provides essential knowledge on the principles, design procedures, and practical applications of combinational circuits in digital systems.
## Key Topics:
- Fundamental differences between combinational and sequential circuits
- Combinational circuit design principles and implementation techniques
- Detailed coverage of critical components including adders, subtractors, BCD adders, and magnitude comparators
- Practical implementations of multiplexers/demultiplexers, encoders/decoders, and parity checkers
- Code converters and BCD to 7-segment decoder designs
- Logic gate interconnections for specific output requirements
This educational resource is ideal for undergraduate and graduate engineering students, electronics professionals, and digital circuit designers seeking to enhance their understanding of combinational logic implementation. Dr. Virdi draws on his extensive research experience to provide clear explanations of complex digital electronics concepts.
Perfect for classroom instruction, self-study, or professional development in electronic engineering, computer engineering, and related technical fields.
Viceroys of India & Their Tenure Key Events During British RuleDeeptiKumari61
油
The British Raj in India (1857-1947) saw significant events under various Viceroys, shaping the political, economic, and social landscape.
**Early Period (1856-1888):**
Lord Canning (1856-1862) handled the Revolt of 1857, leading to the British Crown taking direct control. Universities were established, and the Indian Councils Act (1861) was passed. Lord Lawrence (1864-1869) led the Bhutan War and established High Courts. Lord Lytton (1876-1880) enforced repressive laws like the Vernacular Press Act (1878) and Arms Act (1878) while waging the Second Afghan War.
**Reforms & Political Awakening (1880-1905):**
Lord Ripon (1880-1884) introduced the Factory Act (1881), Local Self-Government Resolution (1882), and repealed the Vernacular Press Act. Lord Dufferin (1884-1888) oversaw the formation of the Indian National Congress (1885). Lord Lansdowne (1888-1894) passed the Factory Act (1891) and Indian Councils Act (1892). Lord Curzon (1899-1905) introduced educational reforms but faced backlash for the Partition of Bengal (1905).
**Rise of Nationalism (1905-1931):**
Lord Minto II (1905-1910) saw the rise of the Swadeshi Movement and the Muslim League's formation (1906). Lord Hardinge II (1910-1916) annulled Bengals Partition (1911) and shifted Indias capital to Delhi. Lord Chelmsford (1916-1921) faced the Lucknow Pact (1916), Jallianwala Bagh Massacre (1919), and Non-Cooperation Movement. Lord Reading (1921-1926) dealt with the Chauri Chaura Incident (1922) and the formation of the Swaraj Party. Lord Irwin (1926-1931) saw the Simon Commission protests, the Dandi March, and the Gandhi-Irwin Pact (1931).
**Towards Independence (1931-1947):**
Lord Willingdon (1931-1936) introduced the Government of India Act (1935), laying India's federal framework. Lord Linlithgow (1936-1944) faced WWII-related crises, including the Quit India Movement (1942). Lord Wavell (1944-1947) proposed the Cabinet Mission Plan (1946) and negotiated British withdrawal. Lord Mountbatten (1947-1948) oversaw India's Partition and Independence on August 15, 1947.
**Final Transition:**
C. Rajagopalachari (1948-1950), Indias last Governor-General, facilitated Indias transition into a republic before the position was abolished in 1950.
The British Viceroys played a crucial role in Indias colonial history, introducing both repressive and progressive policies that fueled nationalist movements, ultimately leading to independence.https://www.youtube.com/@DKDEducation
How to Setup Company Data in Odoo 17 Accounting AppCeline George
油
The Accounting module in Odoo 17 is a comprehensive tool designed to manage all financial aspects of a business. It provides a range of features that help with everything from day-to-day bookkeeping to advanced financial analysis.
Different perspectives on dugout canoe heritage of Soomaa.pdfAivar Ruukel
油
Sharing the story of haabjas to 1st-year students of the University of Tartu MA programme "Folkloristics and Applied Heritage Studies" and 1st-year students of the Erasmus Mundus Joint Master programme "Education in Museums & Heritage".
Team Science in the AI Era: Talk for the Association of Cancer Center Administrators (ACCA) Team Science Network (April 2, 2025, 3pm ET)
Host: Jill Slack-Davis (https://www.linkedin.com/in/jill-slack-davis-56024514/)
20250402 Team Science in the AI Era
These slides: TBD
Jim Twin V1 (English video - Heygen) - https://youtu.be/T4S0uZp1SHw
Jim Twin V1 (French video - Heygen) - https://youtu.be/02hCGRJnCoc
Jim Twin (Chat) Tmpt.me Platform https://tmpt.app/@jimtwin
Jim Twin (English video OpenSource) https://youtu.be/mwnZjTNegXE
Jim Blog Post - https://service-science.info/archives/6612
Jim EIT Article (Real Jim) - https://www.eitdigital.eu/newsroom/grow-digital-insights/personal-ai-digital-twins-the-future-of-human-interaction/
Jim EIT Talk (Real Jim) - https://youtu.be/_1X6bRfOqc4
Reid Hoffman (English video) - https://youtu.be/rgD2gmwCS10
Different Facets of Knowledge on different View.pptxNrapendraVirSingh
油
Knowledge is a fundamental aspect of human understanding, evolving through different dimensions and perspectives. The nature of knowledge varies depending on its scope, application, and contextual relevance. In this lecture, we explore four key distinctions in knowledge: Particular vs. Universal, Concrete vs. Abstract, Practical vs. Theoretical, and Textual vs. Contextual. Each of these dichotomies helps us comprehend how knowledge is categorized, interpreted, and applied across different fields of study.
General Quiz at Maharaja Agrasen College | Amlan Sarkar | Prelims with Answer...Amlan Sarkar
油
Prelims (with answers) + Finals of a general quiz originally conducted on 13th November, 2024.
Part of The Maharaja Quiz - the Annual Quiz Fest of Maharaja Agrasen College, University of Delhi.
Feedback welcome at amlansarkr@gmail.com
Unit No 4- Chemotherapy of Malignancy.pptxAshish Umale
油
In the Pharmacy profession there are many dangerous diseases from which the most dangerous is cancer. Here we study about the cancer as well as its treatment that is supportive to the students of semester VI of Bachelor of Pharmacy. Cancer is a disease of cells of characterized by Progressive, Persistent, Perverted (abnormal), Purposeless and uncontrolled Proliferation of tissues. There are many types of cancer that are harmful to the human body which are responsible to cause the disease condition. The position 7 of guanine residues in DNA is especially susceptible. Cyclophosphamide is a prodrug converted to the active metabolite aldophosphamide in the liver. Procarbazine is a weak MAO inhibitor; produces sedation and other CNS effects, and can interact with foods and drugs. Methotrexate is one of the most commonly used anticancer drugs. Methotrexate (MTX) is a folic acid antagonist. 6-MP and 6-TG are activated to their ribonucleotides, which inhibit purine ring biosynthesis and nucleotide inter conversion. Pyrimidine analogue used in antineoplastic, antifungal and anti psoriatic agents.
5-Fluorouracil (5-FU) is a pyrimidine analog. It is a complex diterpin taxane obtained from bark of the Western yew tree. Actinomycin D is obtained from the fungus of Streptomyces species. Gefitinib and Erlotinib inhibit epidermal growth factor receptor (EGFR) tyrosine kinase. Sunitinib inhibits multiple receptor tyrosine kinases like platelet derived growth factor (PDGF) Rituximab target antigen on the B cells causing lysis of these cells.
Prednisolone is 4 times more potent than hydrocortisone, also more selective glucocorticoid, but fluid retention does occur with high doses. Estradiol is a major regulator of growth for the subset of breast cancers that express the estrogen receptor (ER, ESR1).
Finasteride and dutasteride inhibit conversion of testosterone to dihydrotestosterone in prostate (and other tissues), have palliative effect in advanced carcinoma prostate; occasionally used. Chemotherapy in most cancers (except curable cancers) is generally palliative and suppressive. Chemotherapy is just one of the modes in the treatment of cancer. Other modes like radiotherapy and surgery are also employed to ensure 'total cell kill'.
Stages of combustion, Ignition lag, Flame propagation, Factors affecting flame
speed, Abnormal combustion, Influence of engine design and operating
variables on detonation, Fuel rating, Octane number, Fuel additives, HUCR,
Requirements of combustion chambers of S.I. Engines and its types.
Managing Online Signature and Payment with Odoo 17Celine George
油
Odoo Digital Signature is a feature that allows users to sign documents electronically within the Odoo platform. This functionality streamlines workflows by enabling the creation, distribution, and signing of documents digitally, reducing the need for physical paperwork and speeding up processes.
Behold a thrilling general quiz set brought to you by THE QUIZ CLUB OF PSG COLLEGE OF ARTS & SCIENCE, COIMBATORE, made of 26 questions for the each letter of the alphabet and covering everything above the earth and under the sky.
Explore the trivia , knowledge , curiosity
So, get seated for an enthralling quiz ride.
Quizmaster : THANVANTH N A (Batch of 2023-26), THE QUIZ CLUB OF PSG COLLEGE OF ARTS & SCIENCE, Coimbatore
2. Variables
A variable is a location where some
value is stored - the upper left drawer
A value might be the current checkbook
balance
A variable has a name - Which drawer?
A variable has a type - What can be
stored in the drawer?
X
Y
3. Rules for Variable Names
Variable names start with a letter or an
underscore and consist of numbers, letters,
or underscores
Good names: x1 i abc123
Bad names: x+1 52pickup t&e
C++ is case sensitive
X1 and x1 are different variables
Variable names can be any length
4. Variable Types
Each variable in C++ must have a type
The type determines what can be legally
stored in a variable
The type determines how much storage a
variable occupies
C++ has some built-in types
Later we will define our own new types and
then declare variables our types
X
J
1123 3.1415
5. Some Built-In Types
C++ Type Examples Legal Values
short 1, -43, 1024 -/+ 32,767
int 1, -43, 1024 -/+ 2,147,483,647
long 1, -43, 1024 -/+ 2,147,483,647
char a b 0 All single character values
float 0.001 3.14 -10.2 10-38
to 1038
Seven digits of accuracy
double 1.56 -0.1 46.3 10-308
to 10308
Fifteen digits of accuracy
Note: On some systems the int type has a range of +/- 32,767
6. Declaring Variables
At the beginning of a block of code, we
declare variables for that block of code.
We give each variable a type and a
name
main()
{
int i;
float bankbal;
char initial;
}
7. Assignment Statements
Set a variable to a value
A variable can only hold one value
The next assignment
replaces the variable
contents
X
3.1415
X = 3.1415
100.0
X = 100.0
3.1415
X
8. This is not Algebra
In Algebra x=5 means For the
purposes of this problem, x is 5
In programming, x=5 means:
X=5
Go find the memory location called
x, blast whatever is in it, and set it to
5. And I mean NOW!
178829
X
5
9. Still More
main () {
int ed,mary;
ed = 17;
mary = 2 * ( 14 + ed );
ed = ed + 3;
}
The right-hand side
can be an
expression instead
of a constant
The expression is
computed BEFORE
the assignment
occurs
ed
mary
10. In the Beginning...
What values are in
variables right at the
beginning of the
program?
main () {
int ed,mary;
ed = mary;
}
??????
ed
11. In the Beginning...
What values are in
variables right at the
beginning of the
program?
Garbage, bad stuff,
smelly leftovers
Behavior is officially
undefined
Dont assume zero
main () {
int ed,mary;
ed = mary;
}
??????
ed
12. Defining the Undefined
There is a simple solution - we specify
the initial value as part of the
declaration of the variable.
The syntax looks like an assignment
Ed does not stay zero
Ed just starts out
containing the value zero*
main () {
int ed = 0;
int mary=17;
ed = mary;
}
*Apologies to anyone named Ed - it is just an example
13. A Program
main () {
float celsius;
float faren;
celsius = 33.2;
faren = ( (celsius * 9 ) / 5) + 32.0;
}
celsius
faren
14. Language Assignment Syntax
APL X 20
Pascal X := 20
COBOL MOVE 20 TO X
BASIC LET X = 20
FORTRAN X = 20
C and C++ X = 20
The History of Assignment
There is disagreement among computer
languages as to how to represent this
act of moving data into a variable
15. Running A Program
main () {
float celsius;
float faren;
celsius = 33.2;
faren = ( (celsius * 9 ) / 5) + 32.0;
}
Output:
% g++ samp1.c
% a.out
%
Run the G++ Compiler
Run the compiled program
16. Expressions
Any place a value can be used, an
expression can also be used - the value
is computed from the expression
celsius = 33.2;
faren = ( (celsius * 9 ) / 5) + 32.0;
17. Operators
C/C++ Operator Operation
+ - Addition Subtraction
* / Multiplication Division
% Remainder (Integer division)
Expression Value Notes
3 + 4 7
5 - 1 + 2 6 5 - 1 is done first (left to right)
5 * 2 + 4 14 All multiplication and division is
done before add and subtract
5 * ( 2 + 4 ) 30 Parenthesis rule!
32 % 6 2 The remainder of 32/6 is 2
19. Mixing Types
When expressions mix types, C++
converts data according to rules
char -> int -> long -> float -> double
These rules apply as each sub-expression
is evaluated
For an assignment, the type of the right-
hand-side is converted at the last minute
just before the value is assigned.
21. Input and Output
Programs must interact with something
Keyboard, screen, joystick, speaker,
temperature sensor, keypad (like on a cell
phone)
When a program takes data from
something we call it input
When a program sends its data to
something, we call it output
22. Streams
When we start programming, we keep
things simple - we read from the
keyboard and write to a text screen
In C++ this is done using streams
cin - The input stream
cout - The output stream
23. Ouput Stream
To display information on the screen we
use the insertion operator with cout
#include <iostream.h>
main () {
float celsius;
float faren;
celsius = 33.2;
faren = ( (celsius * 9 ) / 5) + 32.0;
cout << faren;
}
Output:
% g++ samp2.c
% a.out
91.76%
24. Your Responsibility
Computers are getting so fast and so capable
that it will not be long until computers will do
what you want them to do instead of what you
tell them to do.
Gerard P. Weeg (paraphrased ca. 1963)
25. Output Streams
When using cout, we need to manage
the end of lines and white space
End of line
White space
cout << endl; or cout << n;
cout << ; NewLine character
26. #include <iostream.h>
main () {
float celsius;
float faren;
celsius = 33.2;
faren = ( (celsius * 9 ) / 5) + 32.0;
cout << faren;
}
Output:
% g++ samp2.c
% a.out
91.76%
#include <iostream.h>
main () {
float celsius;
float faren;
celsius = 33.2;
faren = ( (celsius * 9 ) / 5) + 32.0;
cout << faren;
cout << endl; // Add A NewLine
}
Output:
% g++ samp3.c
% a.out
91.76
%
We Said We Got
We Wanted
We Needed to Say
27. More cout
You can send multiple things to cout with
multiple << operators
Most people think of the << operator as
send to
means send the value contained in the
variable faren to the screen
cout << Farenheight << faren << endl;
cout << faren;
28. Input
The most basic form of input is from the
keyboard. For this we use the cin input
stream and the >> extraction operator.
Based on the type of the variable
(celsius), a value is read from the
keyboard and stored in the variable
cin >> celsius;
29. A Real Program
#include <iostream.h>
main () {
float celsius;
float faren;
cout << Enter a Celsius Value ;
cin >> celsius;
faren = ( (celsius * 9 ) / 5) + 32.0;
cout << Converted value ;
cout << faren << endl;
}
Output:
% g++ samp4.c
% a.out
Enter a Celsius Value 100
Converted value 212
%
Note Spaces
30. The History of Input/Output
FORTRAN:
READ *,X
PRINT *,X
BASIC:
READ X
PRINT X
C:
scanf(%f,&x);
printf(%f,x);
C++:
cin >> x;
cout << x;
FORTRAN (Formatted):
READ 100,X
100 FORMAT(F8.2)
PRINT 200,X
200 FORMAT(1X,F8.2)
31. A Pattern in Programs
Processing
(Calculations)
Input Output
y = x + 1;
cin >> x; cout << y;
32. Prompting for Input
Another common pattern for interactive
programs is to issue a prompt before
reading input so the user knows what to
type.
.
cout << Enter a Celsius Value ;
cin >> celsius;
faren = ( (celsius * 9 ) / 5) + 32.0;
.
Enter a Celsius Value 100
Converted value 212
Editor's Notes
#8: Algebra is about stating what is true, computer programming is about giving orders. Think about barking out orders orders to move stuff around.