SlideShare a Scribd company logo
   Before I explain any   int main()
                           {
    code to you, I            int i;
    would like you to         int sum = 0;

    execute your first         for(i = 0; i<10; i++){
                                   sum += i;
    program by                 }
    copying and
                               printf("Sum = %dn", sum);
    pasting my code.           //system("pause");
                               return 0;
                           }
 Locate the compile button and run
  buttons in your program.
 You may alternatively find the compile
  and run button that executes both at
  once.
 You should notice a black box
  appearing and disappearing very
  quickly. That is because I have allowed
  this code to execute without any pause
  statements.
   Programs typically automatically close
    once the final line of code is reached.

   The line system(“pause”); needs to be
    added to “pause” the program in place

   The system pause should be placed right
    before the return 0; line of any program.
    Return 0 is typically used at the end of a
    program to tell the computer the program
    has ended.
   Code is normally presented omitting the
    system("pause"); statement which
    confuses new programmers. Always
    make a mental note to add it in if you
    are testing new code.
 When you place // before a line of
  code, you comment the code out and
  cause the compiler to skip over the
  code.
 Now you can remove the // before the
  system pause line in the example
  program and run the program again to
  see output. If all is correct, you should
  see the output being Sum = 45.
   I want to draw your attention to the first line:
    int main(){
   This is the beginning of your main function. The
    function ends with the use of }.
   Any time you open a { bracket, you must close it with
    a } bracket.
   As you can see with the main function, you can see
    the entire main function enclosed within the { }
    brackets.
   Additional code is allowed within the brackets. This
    includes code that uses another set of { } as well.
   The last { bracket to be opened is the first one to be
    closed when a } bracket is used.
 The main function is the starting point of
  a program and where a compiler first
  starts to execute your code.
 It is required in order to compile your
  code, therefore it would be a good
  practice to use the following template.
int main(){

     //your new written code goes here

     system("pause");
     return 0;
}
   Our program is going to need a way to hold
    our values
   These values are stored in different types of
    variables.
   Integers, floats, and doubles are the main
    “number” holders of a program.
   A variable in C programming must always be
    declared at the top of the program right under
    int main() { if you want to use the variable in
    your program.
   Unlike some programming languages, you may
    not locally declare a variable anywhere.
 An integer is a number only
  representable in a whole number form.
 Integers: 1,2,3,4,5..
 Not Integers: 1.5, 1.7, 2.5, 3.9, 1003.4...
 Integer math is the calculation between
  two integers. The math is calculated as
  you would normally between any two
  numbers except the decimal value is
  dropped. Ex. 1+3=4, 1+.5=1 , 5/4 = 1
   Double and Float variables allow the use of
    decimal numbers. A float has a smaller
    default precision than a double.
   If you declare a float and then try to store
    the number within the float into a double,
    you may be transferring only part of the
    number.
   A float allows at most about 7 decimal
    places precision.
    A double allows at least 7 places.
   To accurately work beyond 7 decimals you
    may require addition resources.
 I typically use only Doubles when working
  with decimals and will work with only
  Doubles within these tutorials.
 The math calculated with a double or
  float does not use integer math. It would
  be safe to assume the calculated
  answer would be similar to the answer
  given in a math class.
 An integer is declared by typing
  int variablename;
 A float is declared by typing
  float variablename;
 A double is declared by typing
  double variablename;
 The variablename is changeable to
  anything starting with a letter and
  anything that has not been assigned to
  a variable yet.
 Multiple variables of the same type are
  declarable by adding a comma after
  the first variable and then typing the
  second.
 int one, two, three;
 The point of a variable is to eventually
  hold data.
 The variable could be initialized
  immediately with a value.
 int one = 1;
 double duck = 12.5;
   To print out the value a variable is holding
    you use the printf statement
   printf(“The variable one = %d”, one);
   As shown above, the text you want printed
    out is held within the quotation marks. A
    %variabletype is added to signal to the
    computer you want to print out a variable.
    int -> %d float -> %fl double -> %lf
   After the comma, you list the variables in
    order that match up with the %variables
 A double could be printed out but it may
  contain too many decimal places.
 Limit a double by using %.#lf for the
  number of decimal places you want to
  be printed out.
 The key “n” to a computer is
  interpreted as a line break.
 When used in a printf statement, it will
  add a line break into the output.
int main(){

        int one = 5.5;
        float two = 7.5;
        double three = 10.5;

        printf("One equals: %d n", one);
        printf("Two equals: %f n", two);
        printf("Three equals: %lf n ", three);

        three = 15;

        printf("Three equals: %lf ", three);

        system("pause");
        return 0;
}
   Programming Template

   Integers, Floats, and Doubles

   Printf statements

More Related Content

What's hot

Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming Language
Explore Skilled
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
vikram mahendra
 
Python - Control Structures
Python - Control StructuresPython - Control Structures
Python - Control Structures
LasithNiro
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
Sokngim Sa
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
lemonmichelangelo
 
1584503386 1st chap
1584503386 1st chap1584503386 1st chap
1584503386 1st chapthuhiendtk4
 
Lecture 9- Control Structures 1
Lecture 9- Control Structures 1Lecture 9- Control Structures 1
Lecture 9- Control Structures 1
Md. Imran Hossain Showrov
 
MATLAB programming tips 2 - Input and Output Commands
MATLAB programming tips 2 - Input and Output CommandsMATLAB programming tips 2 - Input and Output Commands
MATLAB programming tips 2 - Input and Output Commands
Shameer Ahmed Koya
 
Control structure of c language
Control structure of c languageControl structure of c language
Control structure of c language
Digvijaysinh Gohil
 
Matlab syntax
Matlab syntaxMatlab syntax
Matlab syntax
pramodkumar1804
 
Lecture 10 - Control Structures 2
Lecture 10 - Control Structures 2Lecture 10 - Control Structures 2
Lecture 10 - Control Structures 2
Md. Imran Hossain Showrov
 
Basic c# cheat sheet
Basic c# cheat sheetBasic c# cheat sheet
Basic c# cheat sheet
Ahmed Elshal
 
C language assignment help
C language assignment helpC language assignment help
C language assignment help
Online Assignment Help
 
[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++
Muhammad Hammad Waseem
 
Operators
OperatorsOperators
Operators
Allah Ditta
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
Muhammad Hammad Waseem
 
Visula C# Programming Lecture 3
Visula C# Programming Lecture 3Visula C# Programming Lecture 3
Visula C# Programming Lecture 3
Abou Bakr Ashraf
 

What's hot (18)

Types of Statements in Python Programming Language
Types of Statements in Python Programming LanguageTypes of Statements in Python Programming Language
Types of Statements in Python Programming Language
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
 
Python - Control Structures
Python - Control StructuresPython - Control Structures
Python - Control Structures
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
 
1584503386 1st chap
1584503386 1st chap1584503386 1st chap
1584503386 1st chap
 
Lecture 9- Control Structures 1
Lecture 9- Control Structures 1Lecture 9- Control Structures 1
Lecture 9- Control Structures 1
 
MATLAB programming tips 2 - Input and Output Commands
MATLAB programming tips 2 - Input and Output CommandsMATLAB programming tips 2 - Input and Output Commands
MATLAB programming tips 2 - Input and Output Commands
 
Control structure of c language
Control structure of c languageControl structure of c language
Control structure of c language
 
Matlab syntax
Matlab syntaxMatlab syntax
Matlab syntax
 
Lecture 10 - Control Structures 2
Lecture 10 - Control Structures 2Lecture 10 - Control Structures 2
Lecture 10 - Control Structures 2
 
Basic c# cheat sheet
Basic c# cheat sheetBasic c# cheat sheet
Basic c# cheat sheet
 
C language assignment help
C language assignment helpC language assignment help
C language assignment help
 
[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++
 
Operators
OperatorsOperators
Operators
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
 
Visula C# Programming Lecture 3
Visula C# Programming Lecture 3Visula C# Programming Lecture 3
Visula C# Programming Lecture 3
 

Viewers also liked

Mca java application projects completed list(is)
Mca java  application projects completed list(is)Mca java  application projects completed list(is)
Mca java application projects completed list(is)
S3 Infotech IEEE Projects
 
SHOW104: Practical Java
SHOW104: Practical JavaSHOW104: Practical Java
SHOW104: Practical Java
Mark Myers
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
mehul patel
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL file
RACHIT_GUPTA
 

Viewers also liked (6)

Mca java application projects completed list(is)
Mca java  application projects completed list(is)Mca java  application projects completed list(is)
Mca java application projects completed list(is)
 
SHOW104: Practical Java
SHOW104: Practical JavaSHOW104: Practical Java
SHOW104: Practical Java
 
Files
FilesFiles
Files
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
 
File Uploading in PHP
File Uploading in PHPFile Uploading in PHP
File Uploading in PHP
 
Java PRACTICAL file
Java PRACTICAL fileJava PRACTICAL file
Java PRACTICAL file
 

Similar to Programming basics

Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
David Halliday
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
David Halliday
 
Tutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng verTutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng ver
Qrembiezs Intruder
 
C programming perso notes
C programming perso notesC programming perso notes
C programming perso notesMelanie Tsopze
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
Anonymous9etQKwW
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
Max Kleiner
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
Rahul Pandit
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptx
AnkitaVerma776806
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
Haard Shah
 
Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...
Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...
Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...
Dadangsachir WANDA ir.mba
 
C++ Course - Lesson 1
C++ Course - Lesson 1C++ Course - Lesson 1
C++ Course - Lesson 1
Mohamed Ahmed
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
Wingston
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Mohammed Saleh
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Mohammed Saleh
 
Input-output
Input-outputInput-output
Input-output
neda marie maramo
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinarurumedina
 
Programming fundamental 02
Programming fundamental 02Programming fundamental 02
Programming fundamental 02
Suhail Akraam
 
PHP Reviewer
PHP ReviewerPHP Reviewer
PHP Reviewer
Cecilia Pamfilo
 

Similar to Programming basics (20)

Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Tutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng verTutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng ver
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
C programming perso notes
C programming perso notesC programming perso notes
C programming perso notes
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptx
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...
Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...
Enrich enriching mathematics conversi biner 16 pada sisikomputerize indoensia...
 
C++ Course - Lesson 1
C++ Course - Lesson 1C++ Course - Lesson 1
C++ Course - Lesson 1
 
C programming
C programmingC programming
C programming
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Input-output
Input-outputInput-output
Input-output
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
 
Programming fundamental 02
Programming fundamental 02Programming fundamental 02
Programming fundamental 02
 
PHP Reviewer
PHP ReviewerPHP Reviewer
PHP Reviewer
 

Recently uploaded

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 

Recently uploaded (20)

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 

Programming basics

  • 1.
  • 2. Before I explain any int main() { code to you, I int i; would like you to int sum = 0; execute your first for(i = 0; i<10; i++){ sum += i; program by } copying and printf("Sum = %dn", sum); pasting my code. //system("pause"); return 0; }
  • 3.  Locate the compile button and run buttons in your program.  You may alternatively find the compile and run button that executes both at once.  You should notice a black box appearing and disappearing very quickly. That is because I have allowed this code to execute without any pause statements.
  • 4. Programs typically automatically close once the final line of code is reached.  The line system(“pause”); needs to be added to “pause” the program in place  The system pause should be placed right before the return 0; line of any program. Return 0 is typically used at the end of a program to tell the computer the program has ended.
  • 5. Code is normally presented omitting the system("pause"); statement which confuses new programmers. Always make a mental note to add it in if you are testing new code.
  • 6.  When you place // before a line of code, you comment the code out and cause the compiler to skip over the code.  Now you can remove the // before the system pause line in the example program and run the program again to see output. If all is correct, you should see the output being Sum = 45.
  • 7.
  • 8. I want to draw your attention to the first line: int main(){  This is the beginning of your main function. The function ends with the use of }.  Any time you open a { bracket, you must close it with a } bracket.  As you can see with the main function, you can see the entire main function enclosed within the { } brackets.  Additional code is allowed within the brackets. This includes code that uses another set of { } as well.  The last { bracket to be opened is the first one to be closed when a } bracket is used.
  • 9.  The main function is the starting point of a program and where a compiler first starts to execute your code.  It is required in order to compile your code, therefore it would be a good practice to use the following template.
  • 10. int main(){ //your new written code goes here system("pause"); return 0; }
  • 11. Our program is going to need a way to hold our values  These values are stored in different types of variables.  Integers, floats, and doubles are the main “number” holders of a program.  A variable in C programming must always be declared at the top of the program right under int main() { if you want to use the variable in your program.  Unlike some programming languages, you may not locally declare a variable anywhere.
  • 12.  An integer is a number only representable in a whole number form.  Integers: 1,2,3,4,5..  Not Integers: 1.5, 1.7, 2.5, 3.9, 1003.4...  Integer math is the calculation between two integers. The math is calculated as you would normally between any two numbers except the decimal value is dropped. Ex. 1+3=4, 1+.5=1 , 5/4 = 1
  • 13. Double and Float variables allow the use of decimal numbers. A float has a smaller default precision than a double.  If you declare a float and then try to store the number within the float into a double, you may be transferring only part of the number.  A float allows at most about 7 decimal places precision.  A double allows at least 7 places.  To accurately work beyond 7 decimals you may require addition resources.
  • 14.  I typically use only Doubles when working with decimals and will work with only Doubles within these tutorials.  The math calculated with a double or float does not use integer math. It would be safe to assume the calculated answer would be similar to the answer given in a math class.
  • 15.  An integer is declared by typing int variablename;  A float is declared by typing float variablename;  A double is declared by typing double variablename;  The variablename is changeable to anything starting with a letter and anything that has not been assigned to a variable yet.
  • 16.  Multiple variables of the same type are declarable by adding a comma after the first variable and then typing the second.  int one, two, three;
  • 17.  The point of a variable is to eventually hold data.  The variable could be initialized immediately with a value.  int one = 1;  double duck = 12.5;
  • 18. To print out the value a variable is holding you use the printf statement  printf(“The variable one = %d”, one);  As shown above, the text you want printed out is held within the quotation marks. A %variabletype is added to signal to the computer you want to print out a variable.  int -> %d float -> %fl double -> %lf  After the comma, you list the variables in order that match up with the %variables
  • 19.  A double could be printed out but it may contain too many decimal places.  Limit a double by using %.#lf for the number of decimal places you want to be printed out.  The key “n” to a computer is interpreted as a line break.  When used in a printf statement, it will add a line break into the output.
  • 20. int main(){ int one = 5.5; float two = 7.5; double three = 10.5; printf("One equals: %d n", one); printf("Two equals: %f n", two); printf("Three equals: %lf n ", three); three = 15; printf("Three equals: %lf ", three); system("pause"); return 0; }
  • 21. Programming Template  Integers, Floats, and Doubles  Printf statements