Answer to Question #185663 in C++ for Jagadeeshwaran

Question #185663

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


1
Expert's answer
2021-04-29T03:14:35-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS