Advertisement
Hiteshw11

Dart program that removes all occurrences of a specified element from a list.

Nov 16th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.38 KB | Source Code | 0 0
  1. //Dart program that removes all occurrences of a specified element from a list.
  2.  
  3. void main()
  4. {
  5.   int a=2;
  6.   List<int> nums =[1,2,2,3,4,2];
  7.   print("The number of times ${a} is repeated is ${remEle(a,nums)}");
  8.  
  9. }
  10.  
  11. remEle(int a1, List<int> nums1)
  12. {
  13.   int count=0;
  14.   for(int i=0;i<nums1.length;i++)
  15.   {
  16.     if(nums1[i]==a1)
  17.     {
  18.       count++;
  19.     }
  20.   }
  21.   return count;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement