Read OnLine Cpp Program Example
6 - FUNCTION CONCEP | |
---|---|
PRAC 3 | PRAC 4 |
//wap to print addtion in function #include<iostream.h> #include<conio.h> int add(int x,int y) { int c; c=x+y; return c; } void main() { int a,b,ans; clrscr(); cout<<"Enter 1st number:"; cin>>a; cout<<"Enter 2nd number:"; cin>>b; ans=add(a,b); cout<<"Addtion="<<ans; getch(); } ------output------ Enter 1st number:24 Enter 2nd number:24 Addtion=48 |
//wap to print addtion in function #include<iostream.h> #include<conio.h> float add(float x,float y) { float c; c=x+y; return c; } void main() { float a,b,ans; clrscr(); cout<<"Enter 1st number:"; cin>>a; cout<<"Enter 2nd number:"; cin>>b; ans=add(a,b); cout<<"Addtion="<<ans; getch(); } ------output------ Enter 1st number:4 Enter 2nd number:4 Addtion=8 |
Previous | Next |
Download | Download |