\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}{>{\columncolor{Gray}}c}
\newcolumntype{b}{>{\columncolor{white}}c}

\newenvironment<>{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<1>[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 <iostream>\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert<1>{\hspace*{2em}int aValue=3;}}\newline
{\alert<1>{\hspace*{2em}int aAnotherValue=3;}}\newline
{\alert<3>{\hspace*{2em}{if(\alert<2>{aValue==aAnotherValue})}}}\newline
{\alert<4>{\hspace*{2em}\{}}\newline
{\alert<5>{\hspace*{2em}\hspace*{2em}cout$<<$"3 and 3 are the same"$<<$endl;}}\newline
{\alert<4>{\hspace*{2em}\}}}\newline
{\alert<6>{\hspace*{2em}cout$<<$"done with if"$<<$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<1-4>{ \hspace*{2em}\newline}{\alert<5>{3 and 3 are the same}\newline}
\alt<1-5>{ \hspace*{2em} \newline}{\alert<6>{done with if}\newline}
\end{varblock}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}

\alt<1->{\alert<1>{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 <iostream>\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert<1>{\hspace*{2em}int aValue=3;}}\newline
{\alert<1>{\hspace*{2em}int aAnotherValue=3;}}\newline
{\alert<3>{\hspace*{2em}{if(\alert<2>{aValue!=aAnotherValue})}}}\newline
{{\hspace*{2em}\{}}\newline
{{\hspace*{2em}\hspace*{2em}cout$<<$"3 and 3 are different"$<<$endl;}}\newline
{{\hspace*{2em}\}}}\newline
{\alert<4>{\hspace*{2em}cout$<<$"done with if"$<<$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<1-3>{ \hspace*{2em} \newline}{\alert<4>{done with if}\newline}
\end{varblock}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}

\alt<1->{\alert<1>{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<1>[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<1>{\hspace*{2em}int aValue=3;}}\newline
{\alert<1>{\hspace*{2em}int aAnotherValue=3;}}\newline
{\alert<3>{\hspace*{2em}{if(\alert<2>{aValue==aAnotherValue})}}}
{\alert<4>{\{}}\newline
{\alert<5>{\hspace*{2em}\hspace*{2em}cout$<<$"3 and 3 are the same"$<<$endl;}}\newline
{\alert<4>{\hspace*{2em}\}}}\newline
{{\hspace*{2em}else}}
{\{}\newline
{{\hspace*{2em}\hspace*{2em}cout$<<$"3 and 3 are different"$<<$endl;}}\newline
{{\hspace*{2em}\}}}\newline
\alert<6>{{\hspace*{2em}cout$<<$"done with if"$<<$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<1-4>{ \hspace*{2em} \newline}{ {\alert<5>{3 and 3 are the same}}\newline}
\alt<1-5>{ \hspace*{2em} \newline}{{\alert<6>{done with if}}\newline}
\end{varblock}
\setbeamercolor{alerted text}{fg=blue}
\begin{varblock}[4cm]{data}

\alt<1->{\alert<1>{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<1>{\hspace*{2em}int aValue=3;}}\newline
{\alert<1>{\hspace*{2em}int aAnotherValue=3;}}\newline
{\alert<3>{\hspace*{2em}{if(\alert<2>{aValue!=aAnotherValue})}}}
{{\{}}\newline
{{\hspace*{2em}\hspace*{2em}cout$<<$"3 and 3 are different"$<<$endl;}}\newline
{{\hspace*{2em}\}}}\newline
{\alert<4>{\hspace*{2em}else}}
{\alert<5>{\{}}\newline
{\alert<6>{\hspace*{2em}\hspace*{2em}cout$<<$"3 and 3 are the same"$<<$endl;}}\newline
{\alert<5>{\hspace*{2em}\}}}\newline
{\alert<7>{\hspace*{2em}cout$<<$"done with if"$<<$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<1-5>{ \hspace*{2em} \newline}{{\alert<6>{3 and 3 are the same}}\newline}
\alt<1-6>{ \hspace*{2em} \newline}{{\alert<7>{done with if}}\newline}
\end{varblock}
\begin{varblock}[4cm]{data}

\alt<1->{\alert<1>{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 <iostream>\newline
using namespace std;\newline
int main()\newline
\{\newline
 \hspace*{2em} \alert<1>{int i=1};\newline
 \hspace*{2em} \alert<2>{cout$<<$"i is: "$<<$i$<<$endl};\newline
 \hspace*{2em} \alert<3>{i=i+1;}\newline
 \hspace*{2em} \alert<4>{cout$<<$"i is: "$<<$i$<<$endl;}\newline
 \hspace*{2em} \alert<5>{i=i+1;}\newline
 \hspace*{2em} \alert<6>{cout$<<$"i is: "$<<$i$<<$endl;}\newline
 \hspace*{2em} \alert<7>{i=i+1;}\newline
 \hspace*{2em} \alert<8>{cout$<<$"i is: "$<<$i$<<$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<1-1>{ \hspace*{2em} \newline}{{\alert<3>{i is: 1}}\newline}
\alt<1-3>{ \hspace*{2em} \newline}{{\alert<4>{i is: 2}}\newline}
\alt<1-5>{ \hspace*{2em} \newline}{{\alert<6>{i is: 3}}\newline}
\alt<1-7>{ \hspace*{2em} \newline}{{\alert<8>{i is: 4}}\newline}

\end{varblock}

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

\alt<1-2>{\alert<1>{i = 1}}{\alt<3-4>{\alert<3>{i = 2}}{\alt<5-6>{\alert<5>{i = 3}}{\alert<7>{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<1>[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 <iostream>\newline
using namespace std;\newline
int main()\newline
\{\newline
{\hspace*{2em}{for (\alert<1>{int i=1};\alert<14>{\alert<10>{\alert<6>{\alert<2>{\alert<18>{{ i<=4}}}}}};\alert<13>{\alert<9>{\alert<5>{\alert<17>{ i=i+1)}}}}}}\newline
\alert<15>{\alert<11>{\alert<7>{\alert<3>{\hspace*{2em}\{}}}}\newline
\alert<16>{\alert<12>{\alert<8>{\alert<4>{\hspace*{2em}\hspace*{2em}cout$<<$"i is: "$<<$ i$<<$endl;}}}}\newline
\alert<15>{\alert<11>{\alert<7>{\alert<3>{\hspace*{2em}\}}}}}\newline
{\alert<19>{\hspace*{2em}cout$<<$"Done with for"$<<$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<1-3>{ \hspace*{2em} \newline}{{\alert<4>{i is: 1}}\newline}
\alt<1-7>{ \hspace*{2em} \newline}{{\alert<8>{i is: 2}}\newline}
\alt<1-11>{ \hspace*{2em} \newline}{{\alert<12>{i is: 3}}\newline}
\alt<1-15>{ \hspace*{2em} \newline}{{\alert<16>{i is: 4}}\newline}
\alt<1-18>{ \hspace*{2em} \newline}{{\alert<19>{Done with wile}}\newline}
\end{varblock}

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

\alt<1-4>{i = 1}{\alt<5-8>{i = 2}{\alt<9-12>{i = 3}{\alt<13-16>{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<1>[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 <iostream>\newline
using namespace std;\newline
int main()\newline
\{\newline
{\alert<1>{\hspace*{2em}int count = 1;}}\newline
{\alert<3>{\hspace*{2em}while (\alert<19>{\alert<15>{\alert<11>{\alert<7>{\alert<2>{count < 5}} }}})}}\newline
\alert<16>{\alert<12>{\alert<8>{\alert<4>{\hspace*{2em}\{}}}}\newline
\alert<17>{\alert<13>{\alert<9>{\alert<5>{\hspace*{2em}\hspace*{2em}cout$<<$"Count is: "$<<$ count$<<$endl;}}}}\newline
\alert<18>{\alert<14>{\alert<10>{\alert<6>{\hspace*{2em}\hspace*{2em}count=count+1;}}}}\newline
\alert<16>{\alert<12>{\alert<8>{\alert<4>{\hspace*{2em}\}}}}}\newline
{\alert<20>{\hspace*{2em}cout$<<$"Done with wile"$<<$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<1-4>{ \hspace*{2em} \newline}{{\alert<5>{Count is: 1}}\newline}
\alt<1-8>{ \hspace*{2em} \newline}{{\alert<9>{Count is: 2}}\newline}
\alt<1-12>{ \hspace*{2em} \newline}{{\alert<13>{Count is: 3}}\newline}
\alt<1-16>{ \hspace*{2em} \newline}{{\alert<17>{Count is: 4}}\newline}
\alt<1-19>{ \hspace*{2em} \newline}{{\alert<20>{Done with wile}}\newline}
\end{varblock}

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

\alt<1-5>{Count = 1}{\alt<6-9>{Count = 2}{\alt<10-13>{Count = 3}{\alt<14-17>{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}