Search found 38 matches

by ganache
Nov 05, 2018 4:32
Forum: General
Topic: Print string as x pattern
Replies: 2
Views: 236

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: 236

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: 353

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: 353

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: 1585

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: 1585

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: 1585

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: 932

Re: The Fibonacci series

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

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...
by ganache
Aug 18, 2017 10:09
Forum: Beginners
Topic: Write even and odd array numbers to file
Replies: 4
Views: 612

Write even and odd array numbers to file

'Program uses a random array and stores even and odd numbers in different files. (FreeBASIC) Dim As Integer n, i, evennum, oddnum input "Enter the no. of values in array=";n Dim As Integer arr(n) Randomize Timer for i=1 to n arr(i)=INT(RND(1) * 20) + 1 ' limits the numbers to 1 to 20 next...
by ganache
Jun 21, 2017 4:41
Forum: Beginners
Topic: Printing a pattern of numbers.
Replies: 4
Views: 447

Re: Printing a pattern of numbers.

Many thanks for the tips.
by ganache
Jun 20, 2017 9:25
Forum: Community Discussion
Topic: Why is the forum not secure?
Replies: 3
Views: 905

Why is the forum not secure?

I have noticed that the FB forum (ie the website) is not secure. It says so in the address bar. The other FB forums such as the German language http://www.FreeBASIC-Portal.de or http://www.qbasic.at use a secure connection. (If you look at the protocol in the address bar it says https:\... rather th...
by ganache
Jun 20, 2017 9:10
Forum: Beginners
Topic: Printing a pattern of numbers.
Replies: 4
Views: 447

Re: Printing a pattern of numbers.

Thank you Basic Coder2.
The resulting triangle looks fine when the value of n is 5. If n is larger then the output is not aligned properly
(due to double digit numbers). So i removed the input line.
by ganache
Jun 20, 2017 5:32
Forum: Beginners
Topic: Printing a pattern of numbers.
Replies: 4
Views: 447

Printing a pattern of numbers.

Hi, i am trying to translate this c code. #include<stdio.h> main() { int n, c, d, num = 1, space; printf ("Enter value of n"); scanf("%d",&n); space = n - 1; for ( d = 1 ; d <= n ; d++ ) { num = d; for ( c = 1 ; c <= space ; c++ ) printf(" "); space--; for ( c = 1 ;...
by ganache
Jun 10, 2017 4:49
Forum: General
Topic: Comparing two single dimensional integer arrays
Replies: 2
Views: 216

Comparing two single dimensional integer arrays

Hi, this is a simple program to compare two integer arrays. Dim As Integer i, m, n input "How many values do the two arrays contain?", n Dim As Integer arrone(n), arrtwo(n) print "Enter the values of first array" For i = 1 to n Print " Value"; i; " : "; Input ...

Go to advanced search