Hashing using structures

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> #include <stdlib.h> struct databox{ int data ; int key ; }; struct databox create(int key,int data){ struct databox temp; temp.data = data; temp.key = key; return temp; } int hashIndex(int data,int size){ return data % size ; } int main(){ int size,i,data; printf("Enter The Size:"); scanf("%d",&size); struct databox hasharray[size]; for(i = 0 ;i<size;i++){ printf("Enter the %d ele:",i+1); scanf("%d",&data); hasharray[hashIndex(i+1,size)] = create(i+1,data); } for(i = 0 ;i<size;i++){ printf("%d \n",hasharray[i]); } return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines