05-09-2008, 02:53 AM
|
| | | Join Date: Sep 2007 Location: near Govt College of Science Multan Pakistan
Posts: 9,693
Contact Number: Removed Program / Discipline: BSIT Class Roll Number: 07-15 | |
Use of Function in C++ 1st lecture by Mam... Madam nay Yeh wali file Compile ki thei..
We can understand the main concept of Functions in C++ Language by using this simple program developed by the mam Sidra in the class room Code: #include <iostream>
#include <stdio.h>
using namespace std;
void function1()
{
cout<<"this is function1"<<endl;
}
void function2(int var1,float var2,char var3)
{
cout<<"this is function2"<<endl;
}
int function3()
{
cout<<"this is function3"<<endl;
return 100;
}
float function4()
{
cout<<"this is function4"<<endl;return 100.5;
}
float function5(float var4)
{
cout<<"this is function5"<<endl;
return 100.5;
}
struct dis
{
int f;
int inc;
};
void function6(dis d)
{
cout<<"this is function6"<<endl<<d.f<<endl<<d.inc<<endl;
}
int main()
{
int var;float var2;
dis d1={22,22};
function1();
function2(25,25.0,'b');
var=function3();
cout<<"this value is returned by function3 "<<var<<endl;
var2=function4();
cout<<"this value is returned by function4 "<<var2<<endl;
var2=function5(100.5);
cout<<"this value is returned by function5"<<var2<<endl;
function6(d1);
return 0;
} |