Showing posts with label first program. Show all posts
Showing posts with label first program. Show all posts

C++ | add()

/ 22 Sept 2013 /
Yup, C++, why not C? Because it was boring, for me, I'm enjoying C++ much better, and going to attempt the famous pythagorus calculator for my next program, just as soon as I learn the sqrt() and the pow() functions, unless that's just what they are, then ha.



#include <iostream>
using namespace std;

int add(int a, int b){
 return a + b;
}

int main()
{
 int a, b;
 cout << "Enter first number: "; cin >> a;
 cout << endl << "Enter second number: "; cin >> b;
 cout << endl << "The answer is " << add(a, b) << endl;
 return 0;
}

C | Ah, alas, we are here.

/ 11 Sept 2013 /
Here is my first C program. I KNOW. Ok, i'm gonna attempt to write the fib sequence, without any help, in C, I know it in python, so it won't be that hard, but yes. This is great.



#include <stdio.h>

main() 
{
 printf("\n");
 
 int a = 1, b = 100;
 while(a < b)
 {
  printf(" %d\n", a);
  a *= 2;
 }
 
 return 0;
}

Python | Guessing game

/ 11 Aug 2013 /
I've got to stop making these, JOKES



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from tkinter import *
from random import *

app = Tk()
app.title('Guess the number')
app.geometry('400x300')
ment = IntVar()
num = randint(1, 10)
def rand():
    ges = ment.get()
    if ges > num:
        l = Label(app, text='{} is too high!'.format(ges)).place(x=165, y=70)
    elif ges < num:
        l = Label(app, text='{} is too low!'.format(ges)).place(x=165, y=70)
    elif ges == num:
        l = Label(app, text='{} is correct!'.format(ges)).place(x=165, y=70)
        return

la = Label(app, text='Guess the secret number between 1 and 10!').pack()
guess = Entry(textvariable=ment).pack()
guess_button = Button(app, text='Guess!', command=rand).pack()

app.mainloop()

JavaScript | And it begins...

/ 10 Aug 2013 /
So, I decided to go back to JavaScript, and I am so glad I did, I watched one tutorial on Youtube, and remembered everything I needed, and I even learn a couple more things, such as 'getElementById' which is so BLOODY cool, so I made this little thing, I also made a few calculators, but they're just simple ones, here's the simple search function:



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  <html>
   <head>

  </head>
  <body>
   <script type="text/javascript">
/* Creating a function called goTo() with 0 parameters */
function goTo()
{ 
 /* Telling the function to get what ever is in the 'link_id'
    and add 'http://' to the begining of it, the make it into
    a link, for the button below, 'Search', to function as a search
    button. */
    location.href = 'http://' + document.getElementById('link_id').value; 
}
 </script>

<h2> Search box </h2>
<!-- Connecting the goTo() Function with the text box below, 
  so it will fetch the input typed in. -->
<input type='text' id='link_id'> 
<!-- Creating a button that when click, does the onClick function
  and has the text, 'Search'. -->
<input type='button' value='Search' onClick='goTo(); return false;'>
 </body>
  <html>

Python | Menu

/ 2 Aug 2013 /
o.m.g SO COOL. here it is,  i can not be bothered to post a picture, so just run it yourself.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import sys
from tkinter import *

def mNew():
    mlabel3 = Label(app, text='if this works then omfg').pack()
    return

app = Tk()
ment = StringVar()

app.title('Menu app!')
app.geometry('600x400')


#Menu
menubar=Menu(app)

filemenu=Menu(menubar, tearoff = 1)
filemenu.add_command(label='New', command = mNew)
filemenu.add_command(label='Open')
filemenu.add_command(label='Save As...')
filemenu.add_command(label='Close')

editmenu=Menu(menubar)
editmenu.add_command(label='Canvas')
editmenu.add_command(label='Print')
editmenu.add_command(label='Copy')
editmenu.add_command(label='Paste')



menubar.add_cascade(label='File', menu=filemenu)
menubar.add_cascade(label='Edit', menu=editmenu)

app.config(menu=menubar)












app.mainloop()

Python | I did it.

/ 28 Jul 2013 /
I made and compiled my very first application. Windowed application. '.exe' File. Please hold the applause, and download it. This will take you to a SAFE mediafire download page, god this is cool. And yes I did call it 'skux', and yes the icon is a skull, why? BECAUSE I CAN, MWUHAHAHAHAH. but yeah, here's a screencap of it. ps. When opening it, don't move it out of the folder it comes in, leave it there. make a shortcut (WHY AM I TELLING YOU THIS WHO EVEN READ THIS BLOG HA HA HA)
YES JENNIFER LAWRENCE IS A GODDESS

Python | Pythagoras Calculator

/ 7 Jul 2013 /
This is the first python program I built using nothing but my knowledge, (and code..duh). It's not very complex, at all.. but it got me to a start.


1
2
3
4
5
6
7
8
9
import math

while 1:
     a = int(input("Please enter the value of a: "))
     b = int(input("Please enter the value of b: "))
     c = math.sqrt(a**2 + b**2)
     print("Thank you for using my pythagorus calculator!")
     print("Your answer is: ", c)
     print("Want to try again?…")
 
Copyright © 2010 M(ath)+me, All rights reserved