CJCoding With Joseph
15per day

Check if All Elements Are the Same

An array called nums has already been created for you with the values {10, 10, 10, 10, 10}.

Your task is to check whether every element in the array has the same value. If they are all the same, print "All same". If any element is different, print "Not all same".

The approach is to compare each element to the first element (nums[0]). If you find any element that doesn't match, the array is not all the same.

Since every element in this array is 10, the expected output is:
All same

Expected Output:

All same
Topics:
Arrays
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.