1

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?

Thanks in advance! -- Mike

  • Compile it, run executable with \href{run:...}{Click!}? – AlexG Feb 20 at 13:40
  • 1
    The code as is doesn't produce any output. So, nothing to uncover anyway. – AlexG Feb 20 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 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 at 13:46
  • 1
    @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 at 13:56
2

You can try SageTeX. I dont know anything specific for C/C++, but I am using it for math execution using Sage.

  • 2
    I think this could be a comment not an answer. – Sigur Feb 20 at 13:48
  • @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 at 13:54
  • 5
    So, now you checked and confirmed, you could edit and improve the text. You wrote only try, so IMHO it is a comment, not an answer. to be an answer you could show how to execute the program, as OP asked. – Sigur Feb 20 at 13:57
  • IMO this is an answer to the question. It would be good to add example code and example output to it, and then still it does not do what the OP wanted (a real-time demo) - but @user5325 could not know this because that was posted in a comment after this answer was posted. – Marijn Feb 20 at 14:16
  • 1
    sagetex is also unable to "demonstrate the execution of this C code during the presentation, instead of uncovering output" (taken from OP). What sagetex might be able to do is to achieve exactly the latter, uncovering output it generated for you. – TeXnician Feb 20 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.