Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 49

Thread: Software Projects for Beginners

  1. Top | #21
    Contributor
    Join Date
    Nov 2017
    Location
    seattle
    Posts
    6,876
    Rep Power
    21
    In the 80s I had a COBOL programmer for a room mate, he worked for a lrge insurance company. He carried a pager after hours. If a crash occurred he went in to fix it.

    When writing system code C allowed acces sto registers in the processor and peripheral chips. With memory protection Windows does not allow you to do that directly anymore

    C was called a high level assembler. You can do all the low level bit and register operations that you can do with assembly language.


    C source code -> assembly language code -> machine code binary executables.

  2. Top | #22
    Deus Meumque Jus
    Join Date
    Jun 2010
    Location
    Canada's London
    Posts
    11,424
    Archived
    9,514
    Total Posts
    20,938
    Rep Power
    55
    Quote Originally Posted by steve_bank View Post
    Quote Originally Posted by rousseau View Post

    I definitely feel spoiled having entered the industry in the 10's. There was a steep learning curve to get where I am now, but truth be told I don't find my work that challenging anymore. If I don't know something the answer is on Google. If there is a bug I can use a debugger.

    It's actually quite beautiful in that people can't just walk in off the street and do it (job security), but for me programming feels like breathing, effortless.
    It is about efficiency and cost. There are tools that take scripted pseudo code and generate C code for different platforms. A guy I knew who sold financial SW paid around $0k for the package and $5k per seat. It enabled him to have one sw engineer instead of 3 or 4.

    Knuths Seni Numdrical Algorithms covers the usual stuff like sorting, searching, random number generators. The general algorithms are well know. The book does not include current AI algorithms, Knuths Semi Numerical Algorithms covere just about all of the regular topics.

    Places like Google and Amazon developed new AI, search, storage, and data base techniques that are proprietary. They are where the action is, so to speak.

    MS VS provides low level functions for web apps and GUI creation. The challenge is not in the code, it is learning VS.
    It can still be a challenge, but the challenge often comes from the specific business problem. If someone wants me to write a simple CRUD or web app I can do it in my sleep, but in my current role I occasionally have to engage my brain if the business problem is complicated enough.

    That being said, in my city it's mostly IT departments and not technology companies so I haven't spent a lot of time with anything too complicated.

  3. Top | #23
    Veteran Member none's Avatar
    Join Date
    Apr 2010
    Location
    colorado
    Posts
    2,701
    Rep Power
    43
    OK, delay timer in Javascript.. please?

  4. Top | #24
    the baby-eater
    Join Date
    May 2011
    Location
    Straya
    Posts
    4,350
    Archived
    1,750
    Total Posts
    6,100
    Rep Power
    44
    Quote Originally Posted by none View Post
    OK, delay timer in Javascript.. please?
    setTimeout

  5. Top | #25
    Veteran Member none's Avatar
    Join Date
    Apr 2010
    Location
    colorado
    Posts
    2,701
    Rep Power
    43
    thanks

  6. Top | #26
    Contributor
    Join Date
    Nov 2017
    Location
    seattle
    Posts
    6,876
    Rep Power
    21
    Here is one.

    Without using built in functions write a 4 function calculator that will parse a string and calculate an answer.

    two c variables and addition, multiplication , division, and subtraction.

    For example parse three strings "a = 6" "b = 1.2" "a / (A+b)" and deter,ine an answer

    Make it general so it can handle any combination.

  7. Top | #27
    Veteran Member
    Join Date
    Dec 2010
    Location
    Riverside City
    Posts
    4,599
    Archived
    6,289
    Total Posts
    10,888
    Rep Power
    44
    Quote Originally Posted by steve_bank View Post
    Here is one.

    Without using built in functions write a 4 function calculator that will parse a string and calculate an answer.

    two c variables and addition, multiplication , division, and subtraction.

    For example parse three strings "a = 6" "b = 1.2" "a / (A+b)" and deter,ine an answer

    Make it general so it can handle any combination.
    What kind of notations does it have to be able to handle? For example, is it enough if it can parse "0.12" or does it also have to be able to process "1.2e-1" and ".12"?

  8. Top | #28
    Contributor
    Join Date
    Nov 2017
    Location
    seattle
    Posts
    6,876
    Rep Power
    21
    Something people used to do was write thir own text editor.

  9. Top | #29
    Contributor
    Join Date
    Nov 2017
    Location
    seattle
    Posts
    6,876
    Rep Power
    21
    Keeping myself occupied, the beginnings of a calculator.

    Structured Programming

    1. Break code into mangeable and testable functions.
    2. Limit nested function calls.
    3. Minimize exit points from functions.
    4. Top down sequntial execution.
    5. Use meaningful function and variable names.
    6. Never hard code constants into the code.

    It us easy to write something for yourself. Raking code robust and usable can be more difficult than the actual function of the code.

    When C creates a string it is NULL terminated. When imputing a string from the console the carriage return character is included in the string and has to be stripped.

    The basic error checking is checking for a peoperly terminated string, and checking for invalid characters.

    When staring a project like this I usualy star simple and write basic functions getting a basic application going. Then add incrementally. I keep revisions as I add so I can back up when things get fouled up.

    The code takes an input string and converts it to an integer value. For an exercise you can expand it to handle decmal values. If there us a string error no conversion occurs.

    After that entering variables and parsing an equation string. Then develop a GUI based app.

    I did it as an MS C+ console app. For straight C replace the C++ iostream functions with standard C. If it wer ea real project at the end I would put this into a class object and compile it to a library so I could use it with something else or for somebody else to use.

    #include <iostream>
    #include "stdlib.h"
    #include "stdio.h"
    #include "math.h"
    #include "string.h"

    using namespace std;
    using std::cin;
    using std::cout;

    const int CR = 10; //ASCII carriage return-line feed
    const int TRUE = 1;
    const int FALSE = 0;
    const int NOERROR = 1;
    const int ERROR2 = 2;
    const int ERROR1 = 1;
    const int ERROR = 0;
    const int MLEN = 20; // max string length
    char valid_char[] = "0123456789+-*/.abcd"; //allowed characters
    const int VCLEN = 19; // val char string length
    const int NDEC = 10; // number of digit values

    int check_string_chars(char in_str[], char val_chars[]){
    //check for valid characters
    int i, j,n_in,n_vc,flag;
    n_in = strlen(in_str);
    n_vc = strlen(val_chars);
    flag = TRUE;
    for (i = 0; i < n_in; i++) {
    for (j = 0; j < n_vc; j++) {
    if (in_str[i] == val_chars[j])flag = FALSE;}
    if (flag)return(ERROR);
    flag = TRUE;
    }
    return(NOERROR);
    }// end check_string_chars()

    int str2int(char in_str[],char val_chars[]) {
    int val = 0, digit = 1, n_in,n_max= MLEN;
    int i,j,k;
    n_in = strlen(in_str);
    k = n_in - 1;
    for (i = 0; i < n_in; i++) {
    for (j = 0; j < NDEC; j++) {
    if (in_str[k] == val_chars[j]) {
    val = val + (digit * j);
    digit = digit * 10;
    break;}
    }
    k--;
    }
    return(val);
    }// end str2num()

    int check_valid_string(char in_s[]) {
    // check for null terminated string
    // strip carriage return-line feed
    int i;
    for (i = 0; i < MLEN; i++) {
    if (in_s[i] == NULL) { return(NOERROR); }
    if (in_s[i] == CR) { in_s[i] = NULL; return(NOERROR); }
    }
    return(ERROR);
    }// end check_valid_string()


    int err_check(int elog[]){
    int flag = NOERROR;
    if (elog[0] == ERROR) { flag = ERROR, printf(" INVALID STRING ERROR");}
    if (elog[1] == ERROR) { flag = ERROR, printf(" INVALID CHAR ERROR");}
    return(flag);
    }//end er_check()
    void main(){
    char test_str[] = "123",inc = 'c';
    char in_string[MLEN];
    int i,value = 0,err[4];
    while (inc != 'x') {
    rewind(stdin);
    std::cout << "\n\n enter string --- ";
    fgets(in_string, MLEN, stdin);
    for (i = 0; i < 4; i++)err[i] = NOERROR;
    err[0] = check_valid_string(in_string);
    err[1] = check_string_chars(in_string, valid_char);
    if (err_check(err)) {
    value = str2int(in_string, valid_char);
    std:cout << "\n Value: " << value;}
    std::cout << "\n x abort c continue\n";
    std::cin >> inc;

    }// while
    }// end main()

  10. Top | #30
    the baby-eater
    Join Date
    May 2011
    Location
    Straya
    Posts
    4,350
    Archived
    1,750
    Total Posts
    6,100
    Rep Power
    44
    Decimal number parser in Python, no built-in functions. Returns an integer and a scale instead of a primitive float to avoid floating point precision problems.

    Code:
    from decimal import Decimal
    import random
    import unittest
    
    
    class InvalidDecimalException(BaseException):
        def __init__(self, value):
            super().__init__(self, value, "is not a decimal number")
    
    
    def parse_integer(char):
        if char == "0":
            return 0
        if char == "1":
            return 1
        if char == "2":
            return 2
        if char == "3":
            return 3
        if char == "4":
            return 4
        if char == "5":
            return 5
        if char == "6":
            return 6
        if char == "7":
            return 7
        if char == "8":
            return 8
        if char == "9":
            return 9
        raise Exception(char, "is not an integer")
    
    
    def e(exp):
        value = 1
        index = 0
        while(index < exp):
            value = value * 10
            index += 1
        return value
    
    
    def parse_decimal_number(input_string_value):
        scale = 0
        precision = 0
        digits = []
        seen_decimal_point = False
        for char in input_string_value:
            if char == ".":
                if seen_decimal_point:
                    raise InvalidDecimalException(input_string_value)
                seen_decimal_point = True
            else:
                try:
                    integer = parse_integer(char)
                    if seen_decimal_point:
                        scale += 1
                    digits.append(integer)
                    precision += 1
                except:
                    raise InvalidDecimalException(input_string_value)
        rank = precision - 1
        value = 0
        for digit in digits:
            value += digit * e(rank)
            rank -= 1
        return value, scale
    
    
    class Tests(unittest.TestCase):
    
        def test_parse_decimal_number(self):
            test_values = [
                "0",
                "1",
                "9",
                "40",
                "49",
                "1.1",
                "0.2",
                "0.2",
                "0.24",
                "0.2425",
                "729087540.2425",
                "7290851004827957540.112817498719087194",
            ]
    
            def expected_result(test_value):
                value = int(test_value.replace(".", ""))
                fraction = Decimal(test_value) % 1
                scale = len(str(fraction)) - 2 if fraction else 0
                return value, scale
    
            for test_value in test_values:
                result = parse_decimal_number(test_value)
                self.assertEqual(expected_result(test_value), result)
    
            invalid_test_values = [
                "1.0.0",
                "abasdf",
                "12132s"
            ]
    
            for test_value in invalid_test_values:
                with self.assertRaises(InvalidDecimalException):
                    parse_decimal_number(test_value)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •