Home Study Guide

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Powered By Blogger

Introduction to Computer Programming (Edx CS50)

06.24.15 
CS50
Computer Programming
 Programming is like talking to the machine and tell it what to do. A Typical programming language is called "C". Along the way, C and other programming languages have similar features. Most programming languages have representative statements. Representative statements are the instructions that tell the computer what to do when they start compiling and executing. Representative statements are commonly called functions. Programming languages also have loops which repeats a command or function again and again forever or at a specific time. Programming languages have Boolean expressions that makes an expression to state whether if the state could be true or false. They also have conditions which will execute if the statement is true but will skip over if the statement is false. However writing a command for your program is not enough, you need something to translate it into binary bits or code. The translator is called "compiler", it's job is to take your code and translates it into the machine language.

07.01.15

Lets talk about "Bugs"
  • Computer bugs are mistakes in your program which leads to errors in the entire program. They are much like the little bugs that you see in your environment. Bugs may be small but can lead into a very big disaster which will ruin your entire program. Software bugs are common in practice. Although there are large variety of bugs possible, some bugs occur more  commonly and are frequently the cause of software failures.



  • Examples of bugs in C: 
#include <stdio.h>
     int main()
     {
         printf("This is an example of a buggy program.\n")
      return 0;
     }
   





#include <stdio.h>
     int main()
     {
         printf(This is an example of a buggy program.\n);
      return 0;
     }




                
  If you have can run C in your computer, copy this program, run it and try to see what happens. Remember that small bugs lead to big disasters.


Abstraction: 

 Is a way of representing data in programming. In object-oriented programming, abstraction is one of three central principles (along with encapsulation and inheritance). Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency. In short we can represent data by making your own functions. That way you can shorten the codes you program and solve bugs easily. the C language can give you the capability to actually make your own commands by describing what your custom function can do. It's like making your own puzzle piece to result your own output. Commonly, experienced programmers define a string name and defines the name using pre-made commands.


  • C program data types: 
    • Data types are the strings that you use to represent custom data and use up bits. 
      • Char: Indicates characters you type in your keyboard.
      • Int: Indicates number strings you type in your keyboard. It stretches up to 4 bits or 4 billion digits.
      • Float: Float is short for floating point and is a fundamental (i.e. built into the compiler) type used to define numbers with fractional parts.
        The float type can represent values ranging from approximately 1.5 × 10−45 to 3.4 × 1038 with a precision of 7 digits.
      • Double: It's bigger than float. It is used to represent larger numbers that would reach more than 3.4 x 1038 with an 8 bit precision.
      • Long: Just like double, it has an 8 bit precision and can increment more variables than "int" and slightly avoids "integer overflow" which overloads your program and turn your program into 0.    
Without any of those data types, your data would literally count from zero to one and results an overflow. 

07.22.15

So let's talk some parts useful in C. These parts are mostly arrays, that help your program run efficiently.


  • int main(void): Commonly called void. It specifies that a program should run via it's name file. It's usually paired with int main(); The void functions also helps you make your own command files.
  • int main(int argc, string argv[]): Paired with int main() to help the program declare multiple arguments and array size. Argument Vectors can access stored memory once the vectors reach to a segment error but will be stopped with a debugger. Argument counters and vectors sort programs fundamentally and efficiently. String argv[] means argument vector. The int argc is an argument count which counts all your running arrays to help you keep in track of how much RAM your program is consuming when running. If you visualize string argv[], it would look a lot like this:
  • int main(int argc): Paired with string agrgv[], int argc counts your program and determines memory limit. Unlike argument vectors, argument counters could only store one memory unit.

07.29.15

Algorithm is a self-contained step-by-step set of operations to be performed. Algorithms exist that perform calculation, data processing, and automated reasoning. An algorithm is an effective method that can be expressed within a finite amount of space and time and in a well-defined formal language for calculating a function. Starting from an initial state and initial input, the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input. A computer program can be viewed as an elaborate algorithm. In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem. In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning.
 

No comments:

Post a Comment