Professional Documents
Culture Documents
Semester – I I
Call By Value
Call By Reference
method is that you cannot alter the variable that are used to call
cout<<"\n\n\n";
cout<< " COLUMN\n";
cout<< " 1 2 3";
for(i=0;i<ROW;i++)
{
cout<<"\nROW "<<i+1;
for(j=0;j<COLUMN;J++)
cout<<Exforsys[i][j];
}
pred = 1;
result = 0;
while (i > 0) {
temp = pred + result;
result = pred;
pred = temp;
i = i-1;
}
return(result);
}
int correctInput;
cout << "Enter the base and the exponent:";
cin >> b >> e;
if (!cin) {
cout << "Disaster! Terminating program." <<
endl;
exit(-1);
}
#include <iostream.h>
int smalldiv (int n){
int count;
count = 2;
while (count < n && n % count != 0)
{ count = count + 1;
}
return(count);
}
#include <iostream.h>
typedef int Bool;
const Bool TRUE = 1;
const Bool FALSE = 0;
Bool even (int);
Bool odd (int);
int readPosNum();
void testOneNum();
void panic();
void main ()
{ int i, j, k; i=1; j=2; k=3; cout << endl; cout <<
"Initial values of i, j, and k are: "
<< i << ", " << j << ", and " << k <<
endl << endl;
cout << "f1(i,j,k) = " << f1(i,j,k) << endl; cout <<
"Values of i, j, and k after the call to f1 are: “
<< i << ", " << j << ", and " << k << endl <<
endl;
return(x+y+z);
}
int f3 (int x, int& y, int z) {
x=x+5;
y=y+5;
z=z+5;
return(x+y+z);
}
#include <iostream.h>
using namespace std;
// replace every n occurrences with 7
#define n 7
int main()
{
Copyright@ Amity University
int i, total = 0, y[n] = {6,9,2,4,5,23,12};
for (i=0; i<n; i++)
{
// display the array contents...
cout<<y[i]<<" ";
// do the summing up...
total = total + y[i];
}
// function prototype
int get_total(int*, int);
int main()
• Student Record:
– Name a string
– HW Grades an array of 3 doubles
– Test Grades an array of 2 doubles
– Final Average a double
StudentRecord stu;
StudentRecord s1,s2;
s1.name = "Joe Student";
…
s2 = s1;
Copies the entire structure
int main ()
{
CRectangle rect;
rect.set_values (3,4);
cout << "area: " << rect.area();
return 0;
}
int main ()
{
CRectangle rect (3,4);
CRectangle rectb (5,6);
cout << "rect area: " << rect.area() << endl;
cout << "rectb area: " << rectb.area() << endl;
return 0;
}