Read OnLine Cpp Program Example



6 - FUNCTION CONCEPT
PRAC 1 PRAC 2
//wap to print addtion in function
#include<iostream.h>
#include<conio.h>
void add()
{
int a,b,ans;
clrscr();
cout<<"Enter 1st number:";
cin>>a;
cout<<"Enter 2nd number:";
cin>>b;
ans=a+b;
cout<<"Addition:"<<ans;
}
void main()
{
add();
getch();
}
-----output-----
Enter 1st number:3
Enter 2nd number:4
addtion:7
//wap to print addtion in function
#include<iostream.h>
#include<conio.h>
void add(int x,int y)
{
int ans;
ans=x+y;
cout<<"Addtion="<<ans;
}
void main()
{
int a,b;
clrscr();
cout<<"Enter 1st number:";
cin>>a;
cout<<"Enter 2nd number:";
cin>>b;
add(a,b);
getch();
}
-------output-------
Enter 1st number:5
Enter 2nd number:5
Addtion=10
Previous Next
Download Download