Skip to content

Commit d6b746c

Browse files
authored
Add files via upload
1 parent 144ded9 commit d6b746c

File tree

7 files changed

+160
-0
lines changed

7 files changed

+160
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Function Main
2+
Declare Integer temp, limit, choice, x, continue
3+
Declare Real cube
4+
5+
Assign temp = 1
6+
Assign cube = 0
7+
Loop
8+
Output "MENU: 1. Calculate all the cubes of the numbers before the upper limit. 2. Display all the cubic numbers before the upper limit."
9+
Input choice
10+
Output "Please specify the upper limit based on your selection!"
11+
Input limit
12+
If choice==1
13+
While temp<(sqrt(limit))
14+
Assign cube = temp*temp*temp
15+
If cube<=limit
16+
Output "The cube of " &temp& " is " &cube& ". "
17+
End
18+
Assign temp = temp+1
19+
End
20+
False:
21+
If choice==2
22+
While temp<=limit
23+
Assign cube = temp*temp*temp
24+
Output "The cube of " &temp& " is " &cube& ". "
25+
Assign temp = temp+1
26+
End
27+
False:
28+
Output "No Output! :( Please enter a number within the given range of numericals displayed in the menu."
29+
End
30+
End
31+
Output "Please enter 1 to continue! To stop, enter any other number from your keypad."
32+
Input continue
33+
Do continue==1
34+
End
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Function Main
2+
Declare Integer n
3+
Declare Real temp, sum
4+
5+
Assign sum = 0
6+
Assign temp = 1
7+
Output "Input the number of terms :"
8+
Input n
9+
While temp<=n
10+
Output "1/ " &temp& " + "
11+
Assign sum = sum+1/temp
12+
Assign temp = temp+1
13+
End
14+
Output " Sum of Series upto " &n& " : " &sum
15+
End
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Function Main
2+
Declare Integer choice, n, continue, binary, rem, temp, decimal
3+
4+
Loop
5+
Output "Menu: 1. Decimal to Binary 2. Binary to Decimal 3. Exit"
6+
Input choice
7+
If choice==1
8+
Assign binary = 0
9+
Assign temp = 1
10+
Output "Enter a number to convert: "
11+
Input n
12+
Output "The Binary of " &n& " is "
13+
While n!=0
14+
Assign rem = n%2
15+
Assign n = n/2
16+
Assign binary = binary+(rem*temp)
17+
Assign temp = temp*10
18+
End
19+
Output ""&binary& ". "
20+
False:
21+
If choice==2
22+
Assign decimal = 0
23+
Assign temp = 0
24+
Output "Enter a binary to convert: "
25+
Input n
26+
Output "The number corresponding to " &n& " is "
27+
While n!=0
28+
Assign rem = n%10
29+
Assign n = n/10
30+
Assign decimal = decimal+(rem*(2^temp))
31+
Assign temp = temp+1
32+
End
33+
Output ""&decimal& ". "
34+
End
35+
End
36+
Output "To get back, press 1. To terminate the execution, press any other key."
37+
Input continue
38+
Do continue==1
39+
End
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Function Main
2+
Declare Integer num, temp, c
3+
4+
Assign c = 0
5+
Output "Input a number :"
6+
Input num
7+
If num==1
8+
Output "1 is neither prime nor composite!"
9+
False:
10+
For temp = 2 to num/2
11+
If num%temp==0
12+
Assign c = c+1
13+
End
14+
End
15+
If c==0
16+
Output ""&num& " is a prime number."
17+
False:
18+
Output ""&num& " is not a prime number."
19+
End
20+
End
21+
End
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Function Main
2+
Declare Integer first, second, third, n, temp
3+
4+
Assign first = 0
5+
Assign second = 1
6+
Output "Input number of terms to display :"
7+
Input n
8+
Output "Here is the Fibonacci series upto " &n& " terms :"
9+
Output "" &first& " " &second
10+
For temp = 2 to n-1
11+
Assign third = first+second
12+
Output " " &third
13+
Assign first = second
14+
Assign second = third
15+
End
16+
End
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Function Main
2+
Declare Integer num, digit, rev
3+
4+
Assign rev = 0
5+
Output "Input a number:"
6+
Input num
7+
Output "The number " &num& " in reverse order is: "
8+
While num!=0
9+
Assign digit = num%10
10+
Assign rev = (rev*10)+digit
11+
Assign num = num/10
12+
End
13+
Output rev
14+
End
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Function Main
2+
Declare Integer i, j, lcm, hcf, n1, n2
3+
4+
Assign hcf = 1
5+
Output "Input 1st number for LCM:"
6+
Input n1
7+
Output "Input 2nd number for LCM:"
8+
Input n2
9+
If n1<n2
10+
Assign j = n1
11+
False:
12+
Assign j = n1
13+
End
14+
For i = 1 to j
15+
If ((n1%i==0)&&(n2%i==0))
16+
Assign hcf = i
17+
End
18+
End
19+
Assign lcm = (n1*n2)/hcf
20+
Output "The LCM of " &n1& " and " &n2& " is : " &lcm
21+
End

0 commit comments

Comments
 (0)