Skip to content

Instantly share code, notes, and snippets.

@anisur3036
Last active November 1, 2022 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anisur3036/ac02130a8aebf25d88339ef9bad92627 to your computer and use it in GitHub Desktop.
Save anisur3036/ac02130a8aebf25d88339ef9bad92627 to your computer and use it in GitHub Desktop.
Nested loop example
/*
* 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