<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass{beamer}
\usepackage{verbatim}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{listings}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\usepackage{xcolor,colortbl}

\newcommand{\mc}[2]{\multicolumn{#1}{c}{#2}}
\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{rgb}{0.88,1,1}

\newcolumntype{a}{&gt;{\columncolor{Gray}}c}
\newcolumntype{b}{&gt;{\columncolor{white}}c}

\newenvironment&lt;&gt;{varblock}[2][.9\textwidth]{%
  \setlength{\textwidth}{#1}
  \begin{actionenv}#3%
    \def\insertblocktitle{#2}%
    \par%
    \usebeamertemplate{block begin}}
  {\par%
    \usebeamertemplate{block end}%
  \end{actionenv}}
	
\usetheme{Frankfurt}
\usepackage{movie15}
\title{programming in C++}
\author{Jonas Vejlin}
\date{}

\begin{document}


\maketitle

\begin{frame}
\frametitle{Parts}

\begin{block}{Part 1}
Basic programming
\end{block}
\begin{block}{Part 2}
Control structure such as loops and if-else (Today)
\end{block}
\begin{block}{Part 3}
Vector,Functions and Input/Ouput
\end{block}
\end{frame}
\section{if}
\begin{frame}
\frametitle{Agenda}

 \frametitle{Table of Contents}
\tableofcontents[currentsection,hideallsubsections]

\end{frame}

\subsection{Graphical Representation}
\begin{frame}
\frametitle{Graphical Representation}
\begin{center}
\includegraphics&lt;1&gt;[width=.60\textwidth]{if.png}
\end{center}
\end{frame}
\subsection{Example}
\begin{frame}
\frametitle{When if is true}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include &lt;iostream&gt;\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert&lt;1&gt;{\hspace*{2em}int aValue=3;}}\newline
{\alert&lt;1&gt;{\hspace*{2em}int aAnotherValue=3;}}\newline
{\alert&lt;3&gt;{\hspace*{2em}{if(\alert&lt;2&gt;{aValue==aAnotherValue})}}}\newline
{\alert&lt;4&gt;{\hspace*{2em}\{}}\newline
{\alert&lt;5&gt;{\hspace*{2em}\hspace*{2em}cout$&lt;&lt;$"3 and 3 are the same"$&lt;&lt;$endl;}}\newline
{\alert&lt;4&gt;{\hspace*{2em}\}}}\newline
{\alert&lt;6&gt;{\hspace*{2em}cout$&lt;&lt;$"done with if"$&lt;&lt;$endl;}}\newline
	cin.get();\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{Output}
\alt&lt;1-4&gt;{ \hspace*{2em}\newline}{\alert&lt;5&gt;{3 and 3 are the same}\newline}
\alt&lt;1-5&gt;{ \hspace*{2em} \newline}{\alert&lt;6&gt;{done with if}\newline}
\end{varblock}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}

\alt&lt;1-&gt;{\alert&lt;1&gt;{aValue = 3 \newline aAnotherValue = 3}}{}   
\end{varblock}
\end{column}
\end{columns}
\end{frame}
\frametitle{When if is false}
\begin{frame}
\frametitle{when if is false}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include &lt;iostream&gt;\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert&lt;1&gt;{\hspace*{2em}int aValue=3;}}\newline
{\alert&lt;1&gt;{\hspace*{2em}int aAnotherValue=3;}}\newline
{\alert&lt;3&gt;{\hspace*{2em}{if(\alert&lt;2&gt;{aValue!=aAnotherValue})}}}\newline
{{\hspace*{2em}\{}}\newline
{{\hspace*{2em}\hspace*{2em}cout$&lt;&lt;$"3 and 3 are different"$&lt;&lt;$endl;}}\newline
{{\hspace*{2em}\}}}\newline
{\alert&lt;4&gt;{\hspace*{2em}cout$&lt;&lt;$"done with if"$&lt;&lt;$endl;}}\newline
	cin.get();\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{Output}
\alt&lt;1-3&gt;{ \hspace*{2em} \newline}{\alert&lt;4&gt;{done with if}\newline}
\end{varblock}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}

\alt&lt;1-&gt;{\alert&lt;1&gt;{aValue = 3 \newline aAnotherValue = 3}}{}   
\end{varblock}
\end{column}
\end{columns}
\end{frame}


\section{if else }
\begin{frame}
\frametitle{Agenda}

 \frametitle{Table of Contents}
    \tableofcontents[currentsection,hideallsubsections]
\end{frame}
\begin{frame}
\frametitle{Agenda}

 \frametitle{Table of Contents}
    \tableofcontents[currentsection]
\end{frame}
\subsection{Graphical Representation}
\begin{frame}
\frametitle{Graphical Representation}
\begin{center}
\includegraphics&lt;1&gt;[width=.60\textwidth]{ifelse.png}
\end{center}
\end{frame}
\subsection{Example}
\begin{frame}
\frametitle{When if is true}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
int main()\newline
\{\newline
{\alert&lt;1&gt;{\hspace*{2em}int aValue=3;}}\newline
{\alert&lt;1&gt;{\hspace*{2em}int aAnotherValue=3;}}\newline
{\alert&lt;3&gt;{\hspace*{2em}{if(\alert&lt;2&gt;{aValue==aAnotherValue})}}}
{\alert&lt;4&gt;{\{}}\newline
{\alert&lt;5&gt;{\hspace*{2em}\hspace*{2em}cout$&lt;&lt;$"3 and 3 are the same"$&lt;&lt;$endl;}}\newline
{\alert&lt;4&gt;{\hspace*{2em}\}}}\newline
{{\hspace*{2em}else}}
{\{}\newline
{{\hspace*{2em}\hspace*{2em}cout$&lt;&lt;$"3 and 3 are different"$&lt;&lt;$endl;}}\newline
{{\hspace*{2em}\}}}\newline
\alert&lt;6&gt;{{\hspace*{2em}cout$&lt;&lt;$"done with if"$&lt;&lt;$endl;}}\newline
	cin.get();\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{Output}
\alt&lt;1-4&gt;{ \hspace*{2em} \newline}{ {\alert&lt;5&gt;{3 and 3 are the same}}\newline}
\alt&lt;1-5&gt;{ \hspace*{2em} \newline}{{\alert&lt;6&gt;{done with if}}\newline}
\end{varblock}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}

\alt&lt;1-&gt;{\alert&lt;1&gt;{aValue = 3 \newline aAnotherValue = 3}}{}   
\end{varblock}
\end{column}
\end{columns}
\end{frame}

\begin{frame}
\frametitle{When if is false}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
int main()\newline
\{\newline
{\alert&lt;1&gt;{\hspace*{2em}int aValue=3;}}\newline
{\alert&lt;1&gt;{\hspace*{2em}int aAnotherValue=3;}}\newline
{\alert&lt;3&gt;{\hspace*{2em}{if(\alert&lt;2&gt;{aValue!=aAnotherValue})}}}
{{\{}}\newline
{{\hspace*{2em}\hspace*{2em}cout$&lt;&lt;$"3 and 3 are different"$&lt;&lt;$endl;}}\newline
{{\hspace*{2em}\}}}\newline
{\alert&lt;4&gt;{\hspace*{2em}else}}
{\alert&lt;5&gt;{\{}}\newline
{\alert&lt;6&gt;{\hspace*{2em}\hspace*{2em}cout$&lt;&lt;$"3 and 3 are the same"$&lt;&lt;$endl;}}\newline
{\alert&lt;5&gt;{\hspace*{2em}\}}}\newline
{\alert&lt;7&gt;{\hspace*{2em}cout$&lt;&lt;$"done with if"$&lt;&lt;$endl;}}\newline
	cin.get();\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{Output}
\alt&lt;1-5&gt;{ \hspace*{2em} \newline}{{\alert&lt;6&gt;{3 and 3 are the same}}\newline}
\alt&lt;1-6&gt;{ \hspace*{2em} \newline}{{\alert&lt;7&gt;{done with if}}\newline}
\end{varblock}
\begin{varblock}[4cm]{data}

\alt&lt;1-&gt;{\alert&lt;1&gt;{aValue = 3 \newline aAnotherValue = 3}}{}   
\end{varblock}
\end{column}
\end{columns}
\end{frame}

\section{Intro to loops}

\begin{frame}
\frametitle{Agenda}

 \frametitle{Table of Contents}

    \tableofcontents[currentsection]
\end{frame}


\begin{frame}
\frametitle{Why Loop}
\begin{itemize}
\item Easy way to run a lot of repetitive code
\item Make sure that each iteration does exactly the same
\item Less copy\\paste code (and less copy\\paste bugs)


\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Without Loop}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include &lt;iostream&gt;\newline
using namespace std;\newline
int main()\newline
\{\newline
 \hspace*{2em} \alert&lt;1&gt;{int i=1};\newline
 \hspace*{2em} \alert&lt;2&gt;{cout$&lt;&lt;$"i is: "$&lt;&lt;$i$&lt;&lt;$endl};\newline
 \hspace*{2em} \alert&lt;3&gt;{i=i+1;}\newline
 \hspace*{2em} \alert&lt;4&gt;{cout$&lt;&lt;$"i is: "$&lt;&lt;$i$&lt;&lt;$endl;}\newline
 \hspace*{2em} \alert&lt;5&gt;{i=i+1;}\newline
 \hspace*{2em} \alert&lt;6&gt;{cout$&lt;&lt;$"i is: "$&lt;&lt;$i$&lt;&lt;$endl;}\newline
 \hspace*{2em} \alert&lt;7&gt;{i=i+1;}\newline
 \hspace*{2em} \alert&lt;8&gt;{cout$&lt;&lt;$"i is: "$&lt;&lt;$i$&lt;&lt;$endl;}\newline
\hspace*{2em}	cin.get();\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[3cm]{Output}
\alt&lt;1-1&gt;{ \hspace*{2em} \newline}{{\alert&lt;3&gt;{i is: 1}}\newline}
\alt&lt;1-3&gt;{ \hspace*{2em} \newline}{{\alert&lt;4&gt;{i is: 2}}\newline}
\alt&lt;1-5&gt;{ \hspace*{2em} \newline}{{\alert&lt;6&gt;{i is: 3}}\newline}
\alt&lt;1-7&gt;{ \hspace*{2em} \newline}{{\alert&lt;8&gt;{i is: 4}}\newline}

\end{varblock}

\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}

\alt&lt;1-2&gt;{\alert&lt;1&gt;{i = 1}}{\alt&lt;3-4&gt;{\alert&lt;3&gt;{i = 2}}{\alt&lt;5-6&gt;{\alert&lt;5&gt;{i = 3}}{\alert&lt;7&gt;{i = 4 }} } } 
\end{varblock}

\end{column}

\end{columns}

\end{frame}
\begin{frame}
\frametitle{Agenda}

 \frametitle{Table of Contents}

    \tableofcontents[currentsection]
\end{frame}
\section{For loop}
\subsection{Graphical Representation}
\begin{frame}
\frametitle{Graphical Representation}
\begin{center}
\includegraphics&lt;1&gt;[width=.60\textwidth]{for.png}
\end{center}
\end{frame}
\subsection{Example}
\begin{frame}
\frametitle{Example}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include &lt;iostream&gt;\newline
using namespace std;\newline
int main()\newline
\{\newline
{\hspace*{2em}{for (\alert&lt;1&gt;{int i=1};\alert&lt;14&gt;{\alert&lt;10&gt;{\alert&lt;6&gt;{\alert&lt;2&gt;{\alert&lt;18&gt;{{ i&lt;=4}}}}}};\alert&lt;13&gt;{\alert&lt;9&gt;{\alert&lt;5&gt;{\alert&lt;17&gt;{ i=i+1)}}}}}}\newline
\alert&lt;15&gt;{\alert&lt;11&gt;{\alert&lt;7&gt;{\alert&lt;3&gt;{\hspace*{2em}\{}}}}\newline
\alert&lt;16&gt;{\alert&lt;12&gt;{\alert&lt;8&gt;{\alert&lt;4&gt;{\hspace*{2em}\hspace*{2em}cout$&lt;&lt;$"i is: "$&lt;&lt;$ i$&lt;&lt;$endl;}}}}\newline
\alert&lt;15&gt;{\alert&lt;11&gt;{\alert&lt;7&gt;{\alert&lt;3&gt;{\hspace*{2em}\}}}}}\newline
{\alert&lt;19&gt;{\hspace*{2em}cout$&lt;&lt;$"Done with for"$&lt;&lt;$endl;}}\newline
\hspace*{2em}	cin.get();\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[3cm]{Output}
\alt&lt;1-3&gt;{ \hspace*{2em} \newline}{{\alert&lt;4&gt;{i is: 1}}\newline}
\alt&lt;1-7&gt;{ \hspace*{2em} \newline}{{\alert&lt;8&gt;{i is: 2}}\newline}
\alt&lt;1-11&gt;{ \hspace*{2em} \newline}{{\alert&lt;12&gt;{i is: 3}}\newline}
\alt&lt;1-15&gt;{ \hspace*{2em} \newline}{{\alert&lt;16&gt;{i is: 4}}\newline}
\alt&lt;1-18&gt;{ \hspace*{2em} \newline}{{\alert&lt;19&gt;{Done with wile}}\newline}
\end{varblock}

\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}

\alt&lt;1-4&gt;{i = 1}{\alt&lt;5-8&gt;{i = 2}{\alt&lt;9-12&gt;{i = 3}{\alt&lt;13-16&gt;{i = 4}{i = 5} } } } 
\end{varblock}

\end{column}

\end{columns}
\end{frame}
\section{While loop}
\begin{frame}
\frametitle{Agenda}

 \frametitle{Table of Contents}
    \tableofcontents[currentsection]
\end{frame}
\subsection{Graphical Representation}
\begin{frame}
\frametitle{Graphical Representation}
\begin{center}
\includegraphics&lt;1&gt;[width=.60\textwidth]{while.png}
\end{center}
\end{frame}
\subsection{Example}
\begin{frame}
\frametitle{Example}

\begin{columns}[T]

\begin{column}{0.45\textwidth}
\begin{varblock}[6cm]{Source Code}
\setbeamercolor{alerted text}{fg=blue}
\setbeamerfont{alerted text}{series=\bfseries,family=\ttfamily}
\begin{semiverbatim} \small
\#include &lt;iostream&gt;\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert&lt;1&gt;{\hspace*{2em}int count = 1;}}\newline
{\alert&lt;3&gt;{\hspace*{2em}while (\alert&lt;19&gt;{\alert&lt;15&gt;{\alert&lt;11&gt;{\alert&lt;7&gt;{\alert&lt;2&gt;{count &lt; 5}} }}})}}\newline
\alert&lt;16&gt;{\alert&lt;12&gt;{\alert&lt;8&gt;{\alert&lt;4&gt;{\hspace*{2em}\{}}}}\newline
\alert&lt;17&gt;{\alert&lt;13&gt;{\alert&lt;9&gt;{\alert&lt;5&gt;{\hspace*{2em}\hspace*{2em}cout$&lt;&lt;$"Count is: "$&lt;&lt;$ count$&lt;&lt;$endl;}}}}\newline
\alert&lt;18&gt;{\alert&lt;14&gt;{\alert&lt;10&gt;{\alert&lt;6&gt;{\hspace*{2em}\hspace*{2em}count=count+1;}}}}\newline
\alert&lt;16&gt;{\alert&lt;12&gt;{\alert&lt;8&gt;{\alert&lt;4&gt;{\hspace*{2em}\}}}}}\newline
{\alert&lt;20&gt;{\hspace*{2em}cout$&lt;&lt;$"Done with wile"$&lt;&lt;$endl;}}\newline
	cin.get();\newline
\}
\end{semiverbatim} 
\end{varblock}
\end{column}

\begin{column}{0.45\textwidth}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{Output}
\alt&lt;1-4&gt;{ \hspace*{2em} \newline}{{\alert&lt;5&gt;{Count is: 1}}\newline}
\alt&lt;1-8&gt;{ \hspace*{2em} \newline}{{\alert&lt;9&gt;{Count is: 2}}\newline}
\alt&lt;1-12&gt;{ \hspace*{2em} \newline}{{\alert&lt;13&gt;{Count is: 3}}\newline}
\alt&lt;1-16&gt;{ \hspace*{2em} \newline}{{\alert&lt;17&gt;{Count is: 4}}\newline}
\alt&lt;1-19&gt;{ \hspace*{2em} \newline}{{\alert&lt;20&gt;{Done with wile}}\newline}
\end{varblock}

\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}

\alt&lt;1-5&gt;{Count = 1}{\alt&lt;6-9&gt;{Count = 2}{\alt&lt;10-13&gt;{Count = 3}{\alt&lt;14-17&gt;{Count = 4}{Count = 5} } } } 
\end{varblock}

\end{column}
\end{columns}
\end{frame}


\section{while or for}
\subsection{while or for}
\begin{frame}
\frametitle{when to use the different loops}

For loop
\begin{itemize}
\item When you know exactly how many times you need to run some code
\item Running through each element in a list
\end{itemize}
While loop
\begin{itemize}
\item When you need to run onto a condition a met 
\item Running onto you reach the end of a file
\item Running onto the user gives a specific input
\end{itemize}
\end{frame}


\end{document}</pre></body></html>