Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int is123Array(int array[], int size) {
- int mismatch = 0, result = 0, value, i;
- for (i = 0, value = 1; i < size, value <= 3; i++, value++) {
- if (array[i] != value) {
- mismatch++;
- }
- }
- if (mismatch > 0) {
- result = 0;
- } else {
- result = 1;
- }
- return 0;
- }
- int main() {
- int i, size;
- printf("Enter the size of array: ");
- scanf("%d", &size);
- int array[size];
- printf("\nEnter array values\n");
- for (i = 0; i < size; i++) {
- printf("%d. array element: ", i+1);
- scanf("%d", &array[i]);
- }
- int result = is123Array(array, size;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment