Jump to content

what tech are you perfect at?


yomama

Recommended Posts

  • Replies 79
  • Created
  • Last Reply

Top Posters In This Topic

  • yomama

    19

  • Quickgun_murugan

    10

  • tennisluvr

    5

  • Batman_fan

    4

okay e roju basics of programming eskundam, this will be the first basic program.

puts "Why did i join db?"

puts "I keep coming back to the DB, but why"

now type this in a text editor , and save the file as ex1.rb .rb is the extension we save a file in ruby.

open up the terminal and go to the folder where this file is saved in, example if you saved it on desktop folder say ruby then type this in first

cd users/desktop/ruby

press return you should be in that directory, now type this command in terminal

$ ruby ex1.rb

you will see the top two lines be printed on the screen.

thats the first program, congrats.

now what is puts ? puts means put string , its a function. in built functions just like printf scanf in C or any other language. you dont need to declare any main file or stdio.h files to get the library , thats the beauty of ruby and you see the difference here? you dont need to build a file or run the file through a compiler to build our machine low level files. Ruby interpreter takes care of all the hassles for you. 

Link to comment
Share on other sites

17 hours ago, yomama said:

okay e roju basics of programming eskundam, this will be the first basic program.

puts "Why did i join db?"

puts "I keep coming back to the DB, but why"

now type this in a text editor , and save the file as ex1.rb .rb is the extension we save a file in ruby.

open up the terminal and go to the folder where this file is saved in, example if you saved it on desktop folder say ruby then type this in first

cd users/desktop/ruby

press return you should be in that directory, now type this command in terminal

$ ruby ex1.rb

you will see the top two lines be printed on the screen.

thats the first program, congrats.

now what is puts ? puts means put string , its a function. in built functions just like printf scanf in C or any other language. you dont need to declare any main file or stdio.h files to get the library , thats the beauty of ruby and you see the difference here? you dont need to build a file or run the file through a compiler to build our machine low level files. Ruby interpreter takes care of all the hassles for you. 

*=:

Link to comment
Share on other sites

5 hours ago, Idassamed said:

*=:

thanks man. 

SO today we gonna learn how to comment a code in program, what is the common syntax we use to comment a code. In ruby we can comment code in the below two ways:

# This is a commented line, the symbol is commonly known as pound, but coders prefer to call it octothorpe

// two backslashes are used to comment a line

# comments help to improve readability of a program, we want others to pick up and fix an issue in future.

numbers, symbols, math

 

puts "I will now count my chickens:"

puts "Hens #{25 + 30 / 6}"
puts "Roosters #{100 - 25 * 3 % 4}"

puts "Now I will count the eggs:"

puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6

puts "Is it true that 3 + 2 < 5 - 7?"

puts 3 + 2 < 5 - 7

puts "What is 3 + 2? #{3 + 2}"
puts "What is 5 - 7? #{5 - 7}"

puts "Oh, that's why it's false."

puts "How about some more."

puts "Is it greater? #{5 > -2}"
puts "Is it greater or equal? #{5 >= -2}"
puts "Is it less or equal? #{5 <= -2}"

 

i just copied an example from code the hard way.

As you see, its a simple program that shows how you can use numbers and operators to get the math done.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...