Let A is an integer array of size 10 and array A can only accept 10 integers. Check any negative number is found and array out of bound if size of array exceeds. If found throw an exception.
Sample input:
15,25,-35,15,36
Output:
Negative Number cannot defined
#include<iostream>
using namespace std;
int main ()
{
int a[10],i;
cout << "Enter the array : ";
for(i=0;i<10;i++)
{
cin>>a[i];
if(a[i]<=0)
cout<<"Negative Number cannot defined";
else
cout<<a[i];
}
return 0;
}
Comments
Leave a comment