About

Contact Us

fastflow
A homepage subtitle here And an awesome description here!

Tuesday 6 October 2015

Write a program to enter element in an array.

#include<iostream>
using namespace std;
int main()
{
    int n;
    int array[20];
    cout<<"Enter no of Element to enter:";
    cin>>n;
    cout<<"Enetr Array Elements:"<<endl;
    for(int i=0;i<n;++i)      //loop for enter the element in array.
    {
        cin>>array[i];
    }
    cout<<"Elements are:"<<endl;
       
        for(int i=0;i<n;++i)      //loop for display element.
    {
        cout<<array[i]<<endl;
    }
    }


Write a program to find greatest number in given array.

#include<iostream>
using namespace std;
int main()
{
    int array[10],n,temp=0; // initilize the variables
    cout<<"Enter no of element :";
    cin>>n;
    for(int i=1;i<=n;i++) //loop for enter the array element
    {
        cout<<"Enter element no "<<i<<" is : ";
        cin>>array[i];
     }
    for(int i=1;i<=n;i++) //loop for showing array element
    {
        cout<<"elements are:"<<array[i]<<endl;
    }
    for(int i=1;i<=n;i++)
    {
        if(array[i]>temp)
        temp=array[i];
     }
    cout<<"Greatest no is: "<<temp;
  }
    cout<<temp;
}