This program asks user to enter numbers between 1 and 100. After i run it i get segmentation error. The program doesnt repeat number twice. Can someone help me.
Code:#include<stdio.h> #define SIZE 20 int main(void) { int a[SIZE]; int i; int x; int j; int flag; int idx=0; printf("Enter 20 numbers between 1 and 100\n"); scanf("%d",&a[i]); //this is how to accept multiple numbers for (int i = 0; i < 20;i++){ scanf("%d",&x); a[i]=x; // this is to determine that numbers dont repeat if(i==0){ a[i]=x; idx++; } else{ for( int j=0; j<idx; j++){ } } if(flag !=1){ a[idx]=x; idx++; } printf("The no duplicate values are:\n"); printf("\n%d",x); } return 0; }



LinkBack URL
About LinkBacks



)