Read OnLine C- Program Example

06_FUNCTION CONCEPT
PRAC 3 PRAC 4
//wap to print addtion in function
#include<stdio.h>
#include<conio.h>
int add(int x,int y)
{
int c;
c=x+y;
return c;
}
void main()
{
int a,b,ans;
clrscr();
printf("Enter 1st number:");
scanf("%d",&a);
printf("Enter 2nd number:");
scanf("%d",&b);
ans=add(a,b);
printf("Addtion=%d",ans);
getch();
}
------output------
Enter 1st number:24
Enter 2nd number:24
Addtion=48
//wap to print addtion in function
#include<stdio.h>
#include<conio.h>
float add(float x,float y)
{
float c;
c=x+y;
return c;
}
void main()
{
float a,b,ans;
clrscr();
printf("Enter 1st number:");
scanf("%f",&a);
printf("Enter 2nd number:");
scanf("%f",&b);
ans=add(a,b);
printf("Addtion=%f",ans);
getch();
}
------output------
Enter 1st number:4
Enter 2nd number:4
Addtion=8
Previous Next
Download Download