Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Iterative statement



" ; " after loop



Specifer



Comment



Test expression




Array_find duplicated number and position




// AHF C PROGRAM SOLVING

//solving here 2_D   ARRAY 	programming problem

#include<stdio.h> #include<math.h> int main() { int i,n,arr[100],j,flag=0; printf("Enter the size of the array:"); scanf("%d",&n); printf("\nEnter the element of the array: "); for(i=0;i < n;i++) scanf("%d",&arr[i]); //checking duplicate number and finding its position for(i=0;i < n;i++) { for(j=i+1;j < n;j++) { if(arr[i]==arr[j]&&i!=j) { flag=1; printf("\nDuplicate number= %d\nand position= %d and %d",arr[i],i,j); } } } //this will not work if flag=1 ......... if(flag==0) printf("\nNO DUPLICATE."); return 0; }
OUTPUT:


© 2018 - All rights reserved