Thursday, November 29, 2012

Function : Function without return value, Function return value and Parameter

Function   : Function without return value, Function return value and Parameter
Nama      : Deab Sina
NIM        : 49012078
Jurusan    : D4 TMD ITB Batch 6

This is video about: Function without return value, Function return value and Parameter

 

Link to this video:


Source code: 

===================================================
+ function_without_return_value.cpp
===================================================

#include<iostream>
usingnamespacestd;

// Create function with the name Function1
void Function1()
{
       for (int c=0; c<5; c++)
       {
              cout<<"Study with using Function"<<endl;
       }
}

// Main Function
int main()
{
       // Calling function to execute
       Function1();

       system("pause");
       return 0;
}



===================================================
+ function_return_value.cpp
===================================================

// function_return_value.cpp : Defines the entry point for the console application.

#include"stdafx.h"
#include<iostream>
usingnamespacestd;

// Create the simple function to return string
char* FunctionString()
{
       return"This is function return value\n";
}

// Main function
int _tmain(intargc, _TCHAR* argv[])
{
       // Call and show the reuslt from the function
       cout<<FunctionString();

       system("pause");
       return 0;
}


===================================================
+ insert_parameter_value.cpp
===================================================

// insert_parameter_value.cpp : Defines the entry point for the console application.

#include"stdafx.h"
#include<iostream>
usingnamespacestd;

// Function with insert parameter
intAddOne (int x)
{
       int result;
       result = x + 1;
       return result;
}
// Main function
int _tmain(intargc, _TCHAR* argv[])
{
       // Declaration of variabel the will be use
       // The parameter value will execute
       int Number, result;

       cout<<"Function with insert parameter value. \n";
       cout<<"Insert intger number : ";
       cin>>Number;

       result = AddOne(Number);

       // Show value
       cout<<"The end of value : "<<result<<endl;

       system("pause");
       return 0;
}
  

Show detail about this Modul.

 

 

 

 


No comments:

Post a Comment