1 using c language please explain What is the output of foll

1. using c language, please explain

What is the output of following program? int main() {int n = 310; funcOne(n); funcTwo(&n;); printf(\"%d\", n); return 0;} void funcOne(int n) {n = 240:} void funcTwo(int *n) {n = 120;} No answer text provided. n=240 n=310 n=120

Solution


#include <stdio.h>


int main(){

   int n = 310;
   funcOne(n);
   funcTwo(n);
   printf(\"%d \",n ); // n value in main is 30, so output: 310

   return 0;
}

void funcOne(int n){
   n = 240; // n is call by value, so it can not cha ge original value
}

void funcTwo(int n){
   n = 120
}


Here both function takes parameter by \"Call By Value\", so any local change
inside function in parameter does not change the original value of variable in main function

Output: 310

1. using c language, please explain What is the output of following program? int main() {int n = 310; funcOne(n); funcTwo(&n;); printf(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site