my_add

my_add
Turn-in directory00_my_add/
Files to turn inmy_add.c
Allowed external functionsNone
Type of workFunction
  • Write a program which displays the character c on standard output.
  • To help you get started, we will provide some code for you to copy/paste/edit. Make sure you understand every line before you hand it in!
  • You need to write a function that takes two integers as parameters and returns the result of the addition of the two integers.
#include <stdio.h>

int my_add(int a, int b)
{
    //Your code
}

// WHEN YOU ARE ASKED FOR A FUNCTION 
// WE WILL USE OUR OWN MAIN FUNCTION WITH MORE TEST 
// TO TEST YOUR EXERCISE
// SO YOU NEED TO REMOVE YOUR MAIN FUNCTION
// OR COMMENT IT OUT

//This main is very limited you test your code with more complex inputs and outputs to make sure your function cover all the cases.

int main()
{
    int a = 1;
    int b = 2;
    int result = my_add(a, b);
    //The function printf allows you to print integers and strings to the console easily it's very handy for debugging purposes make sure to always remove it before you submit your work.
    printf("%d\n", result);
    return 0;
}

Example output:

$ ./a.out
3$