Write a C program to perform the following tasks In main Inp

Write a C program to perform the following tasks: In main: Input an integer and call a function to double it using call- by-value in function: Calculate and return double of integer argument

Solution

#include<stdio.h>

int doublenum(int x)// function that doubles the value of x

{

return 2*x;

}

void main()

{

int number,result;

printf(\"enter any integer\");//prompt to read a number

scanf(\"%d\",&number);// the input read through keyboard is stored at address of number
result=doublenum(number);//function call

printf(\"the number after doubling:%d\ \",result);

}

output:

sh-4.3$ gcc -o main *.c                                                                                                       

sh-4.3$ main                                                                                                                  

enter any integer9                                                                                                            

the number after doubling:18                                                                                                  

sh-4.3$                                                                                                                       

              

 Write a C program to perform the following tasks: In main: Input an integer and call a function to double it using call- by-value in function: Calculate and re

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site