# Execute code during beamer presentation

I am preparing a beamer presentation which includes demo of some C, C++ or similar code. As these are demo, the execution time is very little. I was wondering if it is possible to execute the code within the presentation?

To display the code I am using minted. Here is a sample

\documentclass[12pt,xcolor=dvipsnames,mathsf]{beamer}
\usepackage{minted}
\begin{document}
\begin{frame}
\begin{minted}{C}
#include <stdio.h>
void main()
{
int a,b;
return (a+b);
}
\end{minted}
\end{frame}
\end{document}


Is there any way I can demonstrate the execution of this C code during the presentation, instead of uncovering output?

• Compile it, run executable with \href{run:...}{Click!}? – AlexG Feb 20 '19 at 13:40
• The code as is doesn't produce any output. So, nothing to uncover anyway. – AlexG Feb 20 '19 at 13:42
• @AlexG looks a good attempt. Though at a first thought, it appears to me that I will have to save all the code snippets as individual files and give reference to each of them. – Mike V.D.C. Feb 20 '19 at 13:45
• @AlexG The code I gave above is just for a sample. In my case, it is producing an output, which I would like to demonstrate! – Mike V.D.C. Feb 20 '19 at 13:46
• @AlexG terminal IO simulations appears to complicated. Will have a look at it. In any case, thanks for introducing this completely new way of presentation! Wasnt aware of it... – Mike V.D.C. Feb 20 '19 at 13:56

• @Sigur, it is an answer, as it answers the question. Secondly I just now checked that one can execute C/C++ code in sage. And hence sagetex gives a complete solution! – user5325 Feb 20 '19 at 13:54