2. Compiling and Running a C Program
Create a C Program
Create a file named
hello.c
with the following content. There is also a examplec_app.c
file in this directory if you are not sure what to write.#include <stdio.h> int main() { printf("Hello, Compute Canada!\n"); return 0; }Create a Job Script
Create a file named
compile_and_run.sh
with the following content. Likewise there is a examplecompile_job.sh
file in this directory if you are not sure what to write. Feel free the reference that for more detailed explanations.#!/bin/bash #SBATCH --time=00:15:00 #SBATCH --account=def-sponsor00 gcc hello.c -o hello ./helloSubmit the Job
Use the
sbatch
command to submit your job script:sbatch compile_and_run.shMonitor the Job
Check the Output
Cancel Jobs
Additional Resources
Last modified: 21 March 2025