Last active
November 1, 2022 14:22
-
-
Save anisur3036/ac02130a8aebf25d88339ef9bad92627 to your computer and use it in GitHub Desktop.
Nested loop example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Write a C program to take one positive integer N, the size of an array as input. | |
* Then take an integer array of size N as input. | |
* You need to print the values and for every value, you need print other values than that. | |
* See the samples for more clarification. | |
*/ | |
#include <stdio.h> | |
int main() { | |
// Write C code here | |
int i, j, n, m, unique = 0; | |
int value; | |
printf("Size of array: "); | |
scanf("%d", &n); | |
int arr[n]; | |
for(i=0; i<n; i++) { | |
scanf("%d", &arr[i]); | |
} | |
for(i=0;i<n;i++){ | |
printf("%d - ", arr[i]); | |
for(j=0; j<n; j++) { | |
if(arr[i] != arr[j]) { | |
printf("%d ", arr[j]); | |
} | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment