Search found 44 matches

by ganache
Nov 06, 2019 6:13
Forum: General
Topic: count of digits in large number
Replies: 5
Views: 232

Re: count of digits in large number

thanks guys for the suggestions. But it seems that the log method is incorrect. Tried it in c. The code below works for numbers that fit into the largest numeric data type supported by FB. After that I guess the integers start to overflow... Dim As Ulongint number Dim As Integer count input "En...
by ganache
Nov 05, 2019 9:21
Forum: General
Topic: count of digits in large number
Replies: 5
Views: 232

count of digits in large number

here is some code works in c language function countDigit(n As Ulongint) As Integer return INT(log(10(n)) + 1) end function Dim As Integer n input "Enter number: ";n print countDigit(n) Sleep But compiler says expected '' ( " in return statement. No matter how i try to balance the bra...
by ganache
Jul 24, 2019 9:09
Forum: Game Dev
Topic: Chaze in the Maze (Demo)
Replies: 2
Views: 3527

Re: Chaze in the Maze (Demo)

Very nice work JJFlash!
But how to control the white asterix? Pressing arrow keys does not affect the movement. It is random movement, right?
by ganache
Jul 24, 2019 8:51
Forum: Beginners
Topic: remove duplicates (repeat) characters/letters from a string
Replies: 7
Views: 3731

Re: remove duplicates (repeat) characters/letters from a string

Thank you fxm. But suppose I want the second string (i.e. s2) to be appended with * (asterix or star character) to indicate that the rest of the characters are duplicates.How do i do that ? I tried adding a print "*" after If s1[i] = s2[j] Then duplicate = True But that didn't work. by the...
by ganache
Jul 24, 2019 7:05
Forum: Beginners
Topic: remove duplicates (repeat) characters/letters from a string
Replies: 7
Views: 3731

remove duplicates (repeat) characters/letters from a string

Hi, how to remove duplicates from a string?
What if string is randomly generated?
see code

Code: Select all

Dim As String s(49) ' string has 50 characters
Dim As Integer i, c
Randomize Timer
for i=0 to 49
c=INT(RND(1) +26
list(i)=CHR(c+65) 'upper case letters
print list(i);
next i
Sleep
by ganache
Nov 05, 2018 4:32
Forum: General
Topic: Print string as x pattern
Replies: 2
Views: 296

Re: Print string as x pattern

Thanks, srvaldez. The sub and printPattern seem to be throwing up a few errors. But anyways, thanks. I'll see if I can resolve the issues.
by ganache
Nov 02, 2018 14:27
Forum: General
Topic: Print string as x pattern
Replies: 2
Views: 296

Print string as x pattern

My attempt Dim As String s Dim As Integer i, j Input " enter string with odd no of characters:",s For i = 0 to len(s)-1 For j = 0 to len(s) - 1 If i = j or i + j =len(s) - 1 then Print chr(i), ' semicolon Else Print " ", End if Next j Next i Sleep There will be a point of interse...
by ganache
Jan 03, 2018 6:07
Forum: Tips and Tricks
Topic: GCD(Greatest Common Divisor) of two numbers
Replies: 3
Views: 411

Re: GCD(Greatest Common Divisor) of two numbers

In fact, knowing the GCD, we can also find the LCM(Least Common Multiple) Here is a complete program that will find both GCD and LCM of two numbers. declare function gcd(p As Integer, q As Integer) As Integer declare function lcm(p As Integer, q As Integer) As Integer Dim As Integer p, q ' recursive...
by ganache
Jan 03, 2018 5:50
Forum: Tips and Tricks
Topic: GCD(Greatest Common Divisor) of two numbers
Replies: 3
Views: 411

GCD(Greatest Common Divisor) of two numbers

' Program to find GCD(Greatest Common Divisor) of two numbers.

Code: Select all

declare function gcd(p As Integer, q As Integer) As Integer
Dim As Integer p, q

' recursive Euclidean algorithm
function gcd(p As Integer, q As Integer) As Integer
if q = 0 then
return p
end if
return gcd(q, p mod q)
end function

by ganache
Dec 02, 2017 5:29
Forum: Community Discussion
Topic: Passing command line arguments to FB programs
Replies: 20
Views: 1810

Re: Passing command line arguments to FB programs

Add arguments together as numbers(integers)... Dim As Integer i=0, sum=0 Do Dim As String arg = Command(i) If Len(arg) = 0 Then Exit Do print "command line argument " & i & " = """ & arg & """" i += 1 sum+= val(Command(i)) ' val is us...
by ganache
Nov 30, 2017 6:03
Forum: Community Discussion
Topic: Passing command line arguments to FB programs
Replies: 20
Views: 1810

Re: Passing command line arguments to FB programs

argc and argv are macros in FreeBASIC Joshy Yes, those are macros. But I am talking of non-macro usage perhaps. An example: Dim As Integer i = 0 Dim As String arg = command(1) print "Hello ";command(1); " how are you?" Sleep Run like this: if program name is helloarg.exe then ty...
by ganache
Nov 27, 2017 9:05
Forum: Community Discussion
Topic: Passing command line arguments to FB programs
Replies: 20
Views: 1810

Passing command line arguments to FB programs

Command line arguments are used in many, if not most programming languages. Examples: Basic, C/C++, Java, DOS batch file, Python etc. argc and argv refer to arguments in C. Basically argc refers to the count, i.e the no. of arguments being passed argv is a pointer to an array of strings containing t...
by ganache
Oct 19, 2017 5:39
Forum: Beginners
Topic: The Fibonacci series
Replies: 7
Views: 1116

Re: The Fibonacci series

Very nice dodicat!
by ganache
Oct 18, 2017 6:19
Forum: Beginners
Topic: The Fibonacci series
Replies: 7
Views: 1116

The Fibonacci series

This is a program for printing Fibonacci series. Dim As Integer a =-1, b=1, c=0 Dim As Integer i, n=45 print print tab(1);"No.";tab(17);"Fibonacci " print "-------------------------" for i=0 to n c = a+b a = b b = c print i,using "##########";b next i Sleep En...

Go to advanced search