FYBCA ( Sem–II) Assignment No.3 using function.(solved assignment)




Student Name: Shinde Sachin Dadarao.                                      Roll No:149
Program Name:write a program to addition of two numbers using function

#include<stdio.h>
#include<conio.h>
void add();
void main()
{
clrscr();
add();
getch();
}

void add()
 {
 int a,b,c;

 printf("\n enter the value of a-");
 scanf("\n %d",&a);

 printf("\n enter the value of b-");
 scanf("\n %d",&b);

c=a+b;

 printf("\n the addition is %d",c);
  }
/* output
Enter the value of a-48
Enter the value of b-49
The addition is 97 */














Student Name: Shinde Sachin Dadarao.                                      Roll No:149
Program Name: write a program to find factorial of givan number using function

#include<stdio.h>
#include<conio.h>
void fact(int num);
void main()
{
int num;
clrscr();

printf("\n enter the number-");
scanf("\n %d",&num);

fact(num);

getch();
}

void fact(int num1)
 {
 int fact=1,i;

for(i=1;i<=num1;i++)
  {
  fact=fact*i;
  }

 printf("\n factorial is %d",fact);
 }
/* Output
Enter the number-7
Factorial is 5040 */











Student Name: Shinde Sachin Dadarao.                                      Roll No:149
Program Name: write a program to find area of circle using function

#include<stdio.h>
#include<conio.h>
void circle(int r);
void main()
{
int r;
clrscr();

printf("\n enter the value of r-");
scanf("\n %d",&r);

circle(r);

getch();
}

void circle(int r1)
 {
 int area;

 area=3.14*r1*r1;

 printf("\n %d",*** area ***);
 }
/* Output
Enter the value of r-5
*** 78 *** */












Student Name: Shinde Sachin Dadarao.                          Roll No:149
Program Name: write a program to swap two variable using call by value
#include<stdio.h>
#include<conio.h>
void swap(int a,int b);
void main()
{
int a,b;
clrscr();

printf("\n enter the value of a-");
scanf("\n %d",&a);

printf("\n enter the value of b-");
scanf("\n %d",&b);

swap(a,b);

getch();
}

void swap(int a1,int b1)
 {
 int temp;

 temp=a1;
 a1=b1;
 b1=temp;

 printf("\n swapped value a1 is %d",a1);
 printf("\n swapped value b1 is %d",b1);
 }
/* Output
Enter the value of a-10
Enter the value of b-15

Swapped value a1 is 15
Swapped value b1 is 10 */







Student Name: Shinde Sachin Dadarao.                                      Roll No:149
Program Name: write a program to swap two variable using call by reference.
#include<stdio.h>
#include<conio.h>
void swap(int *a,int *b);
void main()
{
int a,b;
clrscr();

printf("\n enter the value of a-");
scanf("\n %d",&a);

printf("\n enter the value of b-");
scanf("\n %d",&b);

swap(&a,&b);

getch();
}

void swap(int *a1,int *b1)
{
int temp;

temp=*a1;
*a1=*b1;
*b1=temp;

printf("\n swapped value a1 is %d",*a1);
printf("\n swapped value b1 is %d",*b1);
}
/* Output
Enter the value of a-49
Enter the value of b-25

Swapped value a1 is 25
Swapped value b1 is 49 */