Algorithms

Check if prime or not
1) int i,m,n, Flag = 0
2) n = user input
3) m = n/2 or Sqrt(n)
4) if n <=1 then not prime
5) loop  i = 2 and i<=m
6) if (n%i==0) , Not prime, Flag = 1, break loop
7) if flag = 0, Number is prime


 Check if prime or not between two numbers;
1) input start and end
2) Run loop between 2
3) create a function isPrime(i) and print if prime.

Isprime(i) algorithm
1) int i,m,n
2) n = user input
3) m = n/2 or Sqrt(n)
4) if n <=1 then not prime
5) loop  i = 2 and i<=m
6) if (n%!=0) , Not prime, Flag = 1, break loop
7) if flag = 0, prime.



 Find the factors of numbers
1) Get the number - should not be prime
2) loop fromi =  2 to number/2
3) if number%i = 0, then print i

 Factorial of Number

1) get the number
2) int fact = 1
3) for i = i to number
4) fact = fact * i print fact

Pattern Problems

1) Solve the problem







2)  Solve the pattern







3. Solve the problem









4. Solve the problem






5. Solve the pattern




6 Solve the pattern










String manipulation in UFT

1. Extract number from a string

By using regular expression


Instead of digit, If only string is required the use regular expression as [^\d]

By using mid function

                                                                     -x-
2. Extract certain string from a string





 using regular expression also this fleet can be achieved, but it will be very complex.

3. Extract all matching string from main string


prints delhi 4 times.

to get the count, use colmatch.value here value = 4.

Another way to handle the same












Excel Operations with UFT

1) Create a Excel file









2) Check if Excel file exist, if not then create Excel



3)  Write data to excel



4) Read Data from Excel