Display timer and progress bar with AVAudioRecorder Swift

  • Drag and drop “Progress View” from the object Library into your view controller.
  • Link progress view with your view controller class.

    @IBOutlet weak var progressView: UIProgressView!


  • Add a label to your view controller and link it.

    @IBOutlet weak var recorderTimer: UILabel!

  • Declare a variable of type NSTimer in your view controller class.

var timer:NSTimer?

  • In viewDidLoad() function of your view controller class copy paste following code

        timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector:Selector("setProgress"), userInfo: nil, repeats: true)


  • Make a function setProgress()

  func setProgress() {

var seconds = (audioRecorder?.currentTime)

var time=String(format: "%0.0f sec",seconds!)

recorderTimer.text = time

var progresscounter:Double=(audioRecorder?.currentTime)!

progressView.progress=Float(progresscounter/10)

}

Inserting a Node in Linked List


public Node InsertInList(Node head,Node nodeToInsert,int position){
		if (head==null) return nodeToInsert;
		int size=length(head);
		if(position>size+1||position<1){
			System.out.println("Position invalid. Valid inputs are from 1 to"+(size+1));
			return head;
		}
		if (position==1){
			nodeToInsert.setNext(head);
			return nodeToInsert;
		}else{
			Node previousNode=head;
			int count=1;
			while(count
	

Find whether number is prime or not


import java.util.Scanner;

public class IsPrime {
	public static void main(String args[]){
		System.out.println("Enter a number");
		Scanner sc = new Scanner(System.in);
		int number=sc.nextInt();
		if(isPrime(number)){
			System.out.println("Number is Prime");
		}else{
			System.out.println("Number is not Prime");
		}
	}

	private static boolean isPrime(int number) {
		if(number<2)return false;
		for(int i=2;i<=Math.sqrt(number);i++){
			if(number%i==0) return false;
		}
		return true;
	}
}