5.3
Enter the code
void blah(int i)
{
printf("In function: the value of i is %d\n", i);
i++;
printf("In function: the value of i after increment is %d\n\n", i);
}
int main(int argc, char *argv[]) {
int num;
num = 3;
blah(num);
printf("In main(): the value of num is %d\n", num);
system("pause");
return 0;
}
• Write a short reflective account of the code concentrating on its functionality and comparing the outputs against the source code.
#include <stdio.h>
//declare a fuction blah that takes a argument i
void blah(int i)
{
//display the value of i before increment
printf("In function: the value of i is %d\n", i);
i++;
//display the value of i after increment
printf("In function: the value of i after increment is %d\n\n", i);
}
int main(int argc, char *argv[]) {
//declare a variable named num;
int num;
//initialize num to 3
num = 3;
//call the function blah and pass the value of num to it
blah(num);
//display the value of num
printf("In main(): the value of num is %d\n", num);
// system("pause");
return 0;
}
Comments
Leave a comment