Professional Documents
Culture Documents
Write a program that inputs a series of integers and passes them one at a time to
function even, which uses the modulus operator to determine whether an integer is
even. The function should take an integer argument and return true if the integer is
even and false otherwise.
#include <iostream.h>
if ( even( x ) )
cout << x << " is an even integer\n\n";
else
cout << x << " is an odd integer\n\n";
}
cout << endl;
return 0;
}
2. Write a program to store and calculate the sum of 5 numbers entered by the user using
array.
#include <iostream.h>
int sum (int a[100],int n)
{
int sum = 0;
sum += a[i];
}
return sum;
}
int main()
{
int n, numbers[100], s = 0;
}
s=sum(numbers,n);
return 0;
}
#include <iostream.h>
int f = 1;
f *= i;
return f;
int main()
int n, fa;
cout << "Enter a number : ";
cin>>n;
fa=fact(n);
return 0;
4. Write a program that add Two Matrices using Multi-dimensional Arrays using
function .
#include <iostream.h>
void sum_two_matrix( int m1[100][100],int m2[100][100],int
s[100][100],int r,int c)
{
int main()
{
int r, c, a[100][100], b[100][100], sum[100][100], i,
j;
cout << endl << "Enter elements of 1st matrix: " <<
endl;
cout<<sizeof(sum);
sum_two_matrix( a, b, sum,r, c);
{
cout << sum[i][j] << " ";
}
cout<<"\n";
}
return 0;
}