Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit assignment 1 and assignment 2 #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
11 changes: 11 additions & 0 deletions mission_1/attacks/chintan/compiler and interpreter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#COMPILER:
A compiler is a program that translates a source program written in some high-level programming language into machine code (binary code) . The generated machine code can be later executed many times against different data each time.

#INTERPRETER:
1) Parse the source code and perform its behavior directly.
2) Translate source code into some efficient intermediate representation and immediately execute this.
3) Explicitly execute stored precompiled code made by compiler which is part of the interpreter system.

#Diffrence between COMPILER and INTERPRETER:
1) COMPILER is a piece of code that translate the whole high level language in to the machine language. INTERPRETER makes a part of the high level language and Convert them into Machine language.
2) If the Error is there than after converting whole Code the Compiler detects. But the INTERPRETER is detect error when the part of high level language is converting into the
17 changes: 17 additions & 0 deletions mission_1/attacks/chintan/executable_file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# how to make a executable file in ruby??
first we have to write the environment path of the file from where the file is execute.
#!/usr/bin/env ruby
in this line the env is run a program in modified environment.

most of the file have read and write acess.but we have to give a executable acess to the file.
to give the acess of executable run the command ls -l hello.rb

to execute the permisson the command is chmod 755 hello.rb

rename the file and remove the extention .rb.
mv hello.rb hello_rb

now find the path using the command echo $PATH
now create a softlink within the /usr/local/bin/ folder.


12 changes: 12 additions & 0 deletions mission_1/attacks/chintan/hello.CPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream.h>
int main()
{
int a,b,c;
cout<<"enter the number a:";
cin>>a;
cout<<"enter the number b:";
cin<<b;
c=a+b;
cout<<"sum is c:"<<c;
return 0;
}
9 changes: 9 additions & 0 deletions mission_1/attacks/chintan/hello.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env ruby
ARGV.each do|a|
puts "Argument: #{a}"
end

a = ARGV[0].to_i
b = ARGV[1].to_i

puts "Result: " ,a+b
7 changes: 7 additions & 0 deletions mission_1/attacks/chintan/hello_rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /usr/bin/ruby
puts "enter the number a"
a=gets.to_i
puts "enter the number b"
b=gets.to_i
c=a+b
print "the addition is",c
20 changes: 20 additions & 0 deletions mission_1/attacks/chintan/ruby.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#What exactly happens when you install ruby?

When we install ruby, it gets stored in /usr/bin/env/ruby.
When we have to execute the ruby file and which is saved other folder than that file is not executable file because ruby give the environment in /usr/bin/env/ruby only.

#Where does it get installed?

The path of the ruby installation is /usr/bin/ruby

#What files are installed?

erb
gem
irb
rake
rdoc
ri
ruby
testrb

Binary file added mission_1/attacks/chintan/ruby.odt
Binary file not shown.
44 changes: 44 additions & 0 deletions mission_2/attacks/chintan/fibo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
def fibo(num)
for num in 0..num
if num == 0 || num == 1
return num
else
return (num-1)+(num-2)
end

end

end
begin
puts "\nenter number for fibonacci"
puts "To exit enter '-1'\n"
puts "Enter number:"
number = gets.chomp
num = number.to_i


if /[^0-9]/.match(number)

if number.to_i == -1
puts "Exit"
else
puts "\nPlease enter valid positive integer\n"
end
else

result = (0..num).inject do | string , num |
string.to_s + "," + fibo(num).to_s
end
if num == 0
result_arr = result
else
result_arr = result.split(",")
end

puts "\nResult:"
puts "you have entered number '#{num}',so f(#{num})is: #{result_arr[num]} "
puts "your series is: #{result}\n\n"
end
end while num != -1


39 changes: 39 additions & 0 deletions mission_2/attacks/chintan/fibo_rec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
def fibo_rec(n)
if n == 0 || n == 1
return n
else
return (fibo_rec(n-1)+fibo_rec(n-2))
end
end
begin
puts "\nenter number for fibonacci"
puts "To exit enter '-1'\n"
puts "Enter number:"
number = gets.chomp
n = number.to_i


if /[^0-9]/.match(number)

if number.to_i == -1
puts "Exit"
else
puts "\nPlease enter valid positive integer\n"
end
else

result = (0..n).inject do | string , n |
string.to_s + "," + fibo_rec(n).to_s
end

if n == 0
result_arr = result
else
result_arr = result.split(",")
end

puts "\nResult:"
puts "you have entered number '#{n}',so f(#{n})is: #{result_arr[n]} "
puts "your series is: #{result}\n\n"
end
end while n != -1