MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

Arrays/18_Menu_Based_problem.cpp:334–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332 return arr3;
333}
334int main()
335{
336 Array *arr1;
337 int ch,sz;
338 int x,index;
339
340 cout<<"Enter Size of Array";
341 scanf("%d",&sz);
342 arr1=new Array(sz);
343
344 do
345 {
346 cout<<"\n\nMenu\n";
347 cout<<"1. Insert\n";
348 cout<<"2. Delete\n";
349 cout<<"3. Search\n";
350 cout<<"4. Sum\n";
351 cout<<"5. Display\n";
352 cout<<"6.Exit\n";
353
354 cout<<"enter you choice ";
355 cin>>ch;
356
357 switch(ch)
358 {
359 case 1: cout<<"Enter an element and index ";
360 cin>>x>>index;
361 arr1->Insert(index,x);
362 break;
363 case 2: cout<<"Enter index ";
364 cin>>index;
365 x=arr1->Delete(index);
366 cout<<"Deleted Element is"<<x;
367 break;
368 case 3:cout<<"Enter element to search";
369 cin>>x;
370 index=arr1->LinearSearch(x);
371 cout<<"Element index "<<index;
372 break;
373 case 4:cout<<"Sum is "<<arr1->Sum();
374 break;
375 case 5:arr1->Display();
376
377 }
378
379 }while(ch<6);
380 return 0;
381}

Callers

nothing calls this directly

Calls 5

InsertMethod · 0.80
DeleteMethod · 0.80
LinearSearchMethod · 0.80
SumMethod · 0.80
DisplayMethod · 0.80

Tested by

no test coverage detected