\documentclass{beamer}
%
%
\makeatletter
\@ifundefined{lhs2tex.lhs2tex.sty.read}%
  {\@namedef{lhs2tex.lhs2tex.sty.read}{}%
   \newcommand\SkipToFmtEnd{}%
   \newcommand\EndFmtInput{}%
   \long\def\SkipToFmtEnd#1\EndFmtInput{}%
  }\SkipToFmtEnd

\newcommand\ReadOnlyOnce[1]{\@ifundefined{#1}{\@namedef{#1}{}}\SkipToFmtEnd}
\usepackage{amstext}
\usepackage{amssymb}
\usepackage{stmaryrd}
\DeclareFontFamily{OT1}{cmtex}{}
\DeclareFontShape{OT1}{cmtex}{m}{n}
  {<5><6><7><8>cmtex8
   <9>cmtex9
   <10><10.95><12><14.4><17.28><20.74><24.88>cmtex10}{}
\DeclareFontShape{OT1}{cmtex}{m}{it}
  {<-> ssub * cmtt/m/it}{}
\newcommand{\texfamily}{\fontfamily{cmtex}\selectfont}
\DeclareFontShape{OT1}{cmtt}{bx}{n}
  {<5><6><7><8>cmtt8
   <9>cmbtt9
   <10><10.95><12><14.4><17.28><20.74><24.88>cmbtt10}{}
\DeclareFontShape{OT1}{cmtex}{bx}{n}
  {<-> ssub * cmtt/bx/n}{}
\newcommand{\tex}[1]{\text{\texfamily#1}}	% NEU

\newcommand{\Sp}{\hskip.33334em\relax}
\newcommand{\NB}{\textbf{NB}}
\newcommand{\Todo}[1]{$\langle$\textbf{To do:}~#1$\rangle$}

\EndFmtInput
\makeatother
%
\author{Piyush P Kurur\\
  Office no: 224\\
  Dept. of Comp. Sci. and Engg.\\
  IIT Kanpur}


\newcommand{\Token}[2][]{\node(#2#1)[token]{#2};}
\newcommand{\Symbol}[2][]{\node(#2#1)[symbol]{#2};}
\newcommand{\Point}[1]{\node(#1)[point]{#1};}

\usepackage{tikz}
\usetikzlibrary{positioning,shapes,chains,fit}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{matrix}
\usetikzlibrary{backgrounds}
\usetikzlibrary{shapes.geometric}
\usepackage{multicol}

\usepackage{algorithm2e}
\usepackage{pgfkeys}

\pgfkeys %
    {%
      /tikz/box/.style={ 
        shape=rectangle,%
        minimum size=1em,%
        top color=white,
        bottom color=red!50!black!50,
        inner sep=0pt,
        draw=black
      },
      /tikz/bbox/.style={
        shape=rectangle,
        minimum size=1em,
        fill=yellow,
        draw=black
      },
      /tikz/bbbox/.style={
        shape=rectangle,
        minimum size=2em,
        fill=blue!50,
        draw=black,
        thick
      },
      /tikz/garbage/.style={%
        starburst,%
        fill=yellow,%
        draw=red
      }
    }



    
\newcommand{\arraythree}[4]{
  \begin{tikzpicture}[node distance=0]
    \pgfsetstrokeopacity{#4};
    \node[#1](a0#3){#2};
    \node[#1, right=of a0#3](a1#3){#2};
    \node[#1, right=of a1#3](a1#3){#2};
  \end{tikzpicture}
}

\newcommand{\arraytwo}[4]{
  \begin{tikzpicture}[node distance=0]
    \pgfsetstrokeopacity{#4};
    \node[#1](a0#3){#2};
    \node[#1,right=of a0#3]{#2};
  \end{tikzpicture}
}
  
\newcommand{\Array}[0]{
  \arraythree{box}{}{a}{1}
}

\newcommand{\AArray}[0]{%
  \arraythree{bbox}{\Array}{b}{0.5}}
\newcommand{\AAArray}[0]{%
  \arraytwo{bbbox}{\AArray}{c}{0.25}}

  
\title{Fundamentals of Computing: Lecture 18}
\date{September 9, 2009}
\begin{document}
\begin{frame}
  \maketitle
\end{frame}

\begin{frame}
  \frametitle{Summary on arrays and pointers}
  
  \begin{itemize}
  \item Arrays are passed as pointers to the first
    element.
  \item A two dimensional array is passed as a pointer
    to an 1 dimensional array e.g \text{\tt int~\char40{}\char42{}a\char41{}\char91{}10\char93{}}.
  \item In general an $n$ dimensional array is passed
    as a pointer to an $n-1$ dimensional array.
  \end{itemize}


\end{frame}

\begin{frame}
  \begin{tikzpicture}
    \matrix {
      \node[box,label=above:$\texttt{int a;}$]{};
      \pgfmatrixnextcell
      \node[label=above:$\texttt{int a[3];}$ ]{\Array};
      \pgfmatrixendrow
      \node[label=above:$\texttt{int a[3];}$ ]{\Array};
      \pgfmatrixnextcell
      \node[label=above:$\texttt{int a[3][3];}$]{\AArray};
      \pgfmatrixendrow
    };
  \end{tikzpicture}

  \begin{tikzpicture}
    \node[label=above:$\texttt{int a[2][3][3];}$]{\AAArray};
  \end{tikzpicture}
\end{frame}

\begin{frame}
  \begin{tabbing}\tt
~~~~~\char35{}include~\char60{}stdio\char46{}h\char62{}\\
\tt ~~~~~\\
\tt ~~~~~int~main\char40{}\char41{}\\
\tt ~~~~~\char123{}\\
\tt ~~~~~~~int~a\char91{}2\char93{}\char91{}3\char93{}~\char61{}~\char123{}11\char44{}12\char44{}13\char44{}~21\char44{}22\char44{}23\char125{}\char59{}\\
\tt ~~~~~~~int~\char42{}ptr\char44{}\char42{}qtr\char59{}\\
\tt ~~~~~~~ptr~\char61{}~~~~~\char40{}int~\char42{}\char41{}~\char40{}a\char43{}1\char41{}\char59{}\\
\tt ~~~~~~~qtr~\char61{}~a\char91{}1\char93{}\char59{}\\
\tt ~~~~~~~printf\char40{}\char34{}\char42{}\char42{}a~~~~\char61{}~\char37{}d\char92{}n\char34{}\char44{}\char42{}\char42{}a\char41{}\char59{}\\
\tt ~~~~~~~printf\char40{}\char34{}\char42{}\char40{}a\char43{}1\char41{}~\char61{}~\char37{}d\char92{}n\char34{}\char44{}~\char42{}\char40{}a\char43{}1\char41{}\char41{}\char59{}\\
\tt ~~~~~~~printf\char40{}\char34{}\char42{}\char40{}a\char43{}1\char41{}~with~cast~\char37{}d\char92{}n\char34{}\char44{}~\char42{}~\char40{}\char40{}int~\char42{}\char41{}~\char40{}a\char43{}1\char41{}\char41{}\char41{}\char59{}\\
\tt ~~~~~~~printf\char40{}\char34{}\char42{}ptr~\char61{}~\char37{}d~\char92{}n\char34{}\char44{}~\char42{}ptr\char41{}\char59{}\\
\tt ~~~~~~~printf\char40{}\char34{}\char42{}qtr~\char61{}~\char37{}d\char92{}n\char34{}\char44{}~\char42{}qtr\char41{}\char59{}\\
\tt ~~~~~\char125{}
\end{tabbing}
\end{frame}


\end{document}

