Monday 21 October 2013

raw code: Integer Array Pre-Calculation [ easiest, user friendly and OOr ]

#include<iostream>
using namespace std;

int n, ar[100];


void takin()

{
cout <<"number of element: "; cin>> n;

cout <<"put in the elements: ";

for(int x=0; x<n; x++)
{
cin>> ar[x];
}
}

void show()

{
cout <<"\nelements are: ";
for(int y=0; y<n; y++)
{
cout <<ar[y] <<' ';
}

}


void precal()

{
cout <<"\n\nPre-Cal: ";
for(int z=0; z<n; z++)
{
ar[z+1]+=ar[z];
cout <<ar[z] <<' ';
}
}

int main()

{
takin(); show(); precal();
cout <<endl<<endl<<endl<<endl<<endl;
return 777;
}

2 comments:

  1. could you pls xplain the use of return 777

    ReplyDelete
  2. sure, you see here the data type of 'return' is integer since the 'main()' function is itself an integer type. now i can make 'return' to hold and send back any integer type data ( of course in a limit and type casting is a different thing) all i have to do is to introduce it to any int number.

    so writing a 'return 0' or 'return 777' is just same thing.

    ReplyDelete