In this program, the task is to create a program having a function with arguments but no return values . So, we create a function outside the main function named as func() . In this function , int func is used as the function returns a variable of type int . Moreover , the function accepts an integer type variable , which are called arguments . A function can only return a single value but in this case we are not returning value . With line a = func(a) , the program passes its control to function & value passes will be stored in function variable a & then it passes the control to main function . Then , we will display the output after calling of the function .
#include<stdio.h>
#include<string.h>
#include<conio.h>
void func(int a);
void main()
{ clrscr();
int a;
printf("enter value of a = ");
scanf("%d",&a);
func(a);
printf("\n\n value of a after calling of function = %d",a);
getch();
}
void func(int a)
{ int b = a;
b = a+10;
printf("value of a inside function = %d",b);
}
#include<string.h>
#include<conio.h>
void func(int a);
void main()
{ clrscr();
int a;
printf("enter value of a = ");
scanf("%d",&a);
func(a);
printf("\n\n value of a after calling of function = %d",a);
getch();
}
void func(int a)
{ int b = a;
b = a+10;
printf("value of a inside function = %d",b);
}

No comments:
Post a Comment
Guys if you think something is wrong or should be edit than please do comment.