Learning C/C++ Step-By-Step
Step-by-Step C/C++ --- Introduction
Many people are really interested in learning and implementing C/C++ programs on their favorite platforms like DOS/Windows or Linux. If you are the one looking for a step-by-step guide to get started, this notes is for you. Let me know your comments on my tiny attempt to serve the community.
http://www.cplusplus.c/
notes 1.
#include<iostream>
using namespace std;
int i,j;
double average ; double total;
double sum(int ami[][6],int row);
double high(int ami[][6],int row);
double rendah(int ami[][6], int row);
void search(int ami[][6],int row);
double calculate(int ami[][6], int row);
void input(int ami[][6],int row)
{
cout<<"Please insert 36 value(s) :";
for(i=0 ; i<row; i++)
{
for(j=0 ; j<row; j++)
{
cin>>ami[i][j];
}
}
cout<<"\t Value in matrix form : "<<endl<<endl;
for(i=0 ; i<row; i++)
{
for(j=0 ; j<row; j++)
{
cout<<"\t"<<ami[i][j]<<" ";
}
cout<<endl<<endl;
}
}
double sum(int ami[][6],int row)
{
double total = 0;
for(i=0; i<row; i++)
{
for(j=0; j<row; j++)
{
total = total + ami[i][j];
}
}
cout<<endl;
return total;
}
double calculate(int ami[][6], int row)
{
for(i=0; i<row; i++)
{
for(j=0; j<row; j++)
{
total = total + ami[i][j];
}
}
average = total/36;
return average;
}
double high(int ami[][6], int row)
{
double hai = 0;
for(i=0 ; i<row; i++)
{
for(j=0; j<row; j++)
{
if(ami[i][j] > hai)
{
hai = ami[i][j];
}
}
}
return hai;
}
double rendah(int ami[][6], int row)
{
double low =999;
for(i=0 ; i<row; i++)
{
for(j=0; j<row; j++)
{
if(ami[i][j] < low)
low = ami[i][j];
}
}
return low;
}
void search(int ami[][6],int row)
{
int value,flag = 0;
cout<<"\t Enter value to search : ";
cin>>value;
cout<<endl;
for(i=0; i<row; i++)
{
for(j=0; j<row; j++)
{
if(value == ami[i][j])
{
cout<<" \t Value is available at [ "<<i<<" ][ "<<j<< " ] "<<endl;
flag = 1;
}
else
cout<<" \t Searching value.......................... "<<endl;
}
}
if(flag != 1)
cout<<"\t NO MATCH FOUND (-1) !"<<endl;
if(flag = 1)
cout<<"\t Finished searching..........."<<endl;
}
void main()
{
int ami[6][6];
input(ami,6);
cout<<"\t Total of all value(s) : "<<sum(ami,6)<<endl<<endl;
cout<<"\t Average value : "<<calculate(ami,6)<<endl<<endl;
cout<<"\t Highest value : "<<high(ami,6)<<endl<<endl;
cout<<"\t Lowest value : "<<rendah(ami,6)<<endl<<endl;
system("pause");
system("pause");
search(ami,6);
}
No comments:
Post a Comment