Files
uni/third/semester1/CT331: Programming Paradigms/notes/_minted-CT331-Notes/1068657127F3286CC09F02C504E452A85F05A55D80B094B3E363B77D3804D2F3.pygtex

26 lines
1.7 KiB
Plaintext

\begin{Verbatim}[commandchars=\\\{\},codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}]
\PYG{c+c1}{// header inclusion: functionally defined in stdio.h is added into the program by the compiler, specifically the Linker step of the compiler}
\PYG{c+c1}{// "stdio" is short for "Standard Input / Output"}
\PYG{c+cp}{\PYGZsh{}include}\PYG{+w}{ }\PYG{c+cpf}{\PYGZlt{}stdio.h>}
\PYG{c+c1}{// function prototype: tells the compiler that the function exists before it has been implemented}
\PYG{c+c1}{// allows the compiler to handle recursion, or functions calling each other}
\PYG{k+kt}{void}\PYG{+w}{ }\PYG{n+nf}{sayHello}\PYG{p}{();}
\PYG{c+c1}{// function definition: implements the function}
\PYG{c+c1}{// note: data type, arguments, return}
\PYG{k+kt}{void}\PYG{+w}{ }\PYG{n+nf}{sayHello}\PYG{p}{()}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
\PYG{+w}{ }\PYG{c+c1}{// calling a function: printf takes a char* argument}
\PYG{+w}{ }\PYG{n}{printf}\PYG{p}{(}\PYG{l+s}{\PYGZdq{}Hello World!}\PYG{l+s+se}{\PYGZbs{}n}\PYG{l+s}{\PYGZdq{}}\PYG{p}{);}
\PYG{p}{\PYGZcb{}}
\PYG{c+c1}{// main function: the entry point to the progam}
\PYG{c+c1}{// returns int}
\PYG{c+c1}{// takes two arguments: argc (the number of command-line arguments) & argv (an array of the arguments)}
\PYG{k+kt}{int}\PYG{+w}{ }\PYG{n+nf}{main}\PYG{p}{(}\PYG{k+kt}{int}\PYG{+w}{ }\PYG{n}{argc}\PYG{p}{,}\PYG{+w}{ }\PYG{k+kt}{char}\PYG{o}{*}\PYG{+w}{ }\PYG{n}{argv}\PYG{p}{[])}\PYG{+w}{ }\PYG{p}{\PYGZob{}}
\PYG{+w}{ }\PYG{c+c1}{// calling a function: sayhello takes no argument. nothing is returned}
\PYG{+w}{ }\PYG{n}{sayHello}\PYG{p}{();}
\PYG{+w}{ }\PYG{k}{return}\PYG{+w}{ }\PYG{l+m+mi}{0}\PYG{p}{;}
\PYG{p}{\PYGZcb{}}
\end{Verbatim}