logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/cs256su21code/jun10/byValue.c

/* 
this version of the program  uses call by value

In call by value, a copy of actual arguments is passed to formal arguments 
of the called function and any change made to the formal arguments in the 
called function have no effect on the values of actual arguments in the calling function.

In call by value, actual arguments will remain safe, they cannot be modified accidentally.

by default, things in C are passed by value

*/
#include <stdio.h>

int doubleNum(int x){

	return x * 2;

}


int main(){

	int num;

	printf("Enter a number: ");
	scanf("%d", &num);



	num = doubleNum(num);

	printf("Double that number is %d\n", num);




}