Tuesday, 7 July 2015

Entering Input and Displaying Output.

In this blog, we'll learn about ...ugh, i'm dropping the cheesy opening lines. Let's talk business. I'm Syntaxberg, making you an offer you cannot refuse.

What if you could enter any input and obtain the desired output? Won't that be something?

In the last program, we had displayed the output using the "printf" parameter. In this program, we'll use the "scanf" parameter for the input.


#include <stdio.h>
#include <conio.h>
int main()
{int  number;
 printf("How many cannons are ready sailor? \n");
 scanf("%d", &number);  //....1
 printf("Arrrgh! Only %d ?", number);
 getch();}




1. Heave ho! Coming directly  to the  point 1, we come across a great adversity of its kind. Scanf. What does it  do? Well, Scanf is the inputting parameter and it is analogous and umn.. antonym..? of printf. If Printf displays the output, scanf scans the input. So, if Cap'n Blackbeard is asking you how many cannons are ready (and you're fellow mates are too lazy to make 'em ready), the Cap'n will reply in anguish and probably feed you to the sharks.




"Arrrgh! The Sharks or the Blunderbuss, mateys?!"





Saturday, 9 May 2015

JESSE, We need to CODE.

Wanna code? Wanna taste Pride and real Glory? Wanna treat a machine like your bottom chick? Make her tap to your beats? If you wish to feel like a real man, you got the right place, boyo.


Dumping my aberrant satire for a while, and returning to my 'not so usual' self, I'd like to introduce you to my Blog ...wait for it... (*Inserts opening theme from Breaking Bad*) CODING BAD. Call me Syntaxberg. Let's begin with my first topic :-

ANSI C PROGRAMMING, An Introduction -

ANSI, (try saying it altogether..or just chuck it) stands for AMERICAN NATIONAL STANDARDS INSTITUTE. The programming language C was developed by Dennis Ritchie back in the 70s. It was evolved from ALGOL (Algorithmic Language) which has it's own background history. Learning this language is an accolade in itself. Let's begin with our first program. A program which basically prints a message. 

A program that prints "Hola Muchachos" (err..yes.) Vamonos! 

#include<conio.h>    //....1
#include<stdio.h>     //....2
int main ()                //.....3
{                               //.....4
printf("Hola Muchachos!");      //.....5
                     
getch();      } //.....6      

Output : Hola Muchachos!




Errr..Ingles, Senor? Ahem. Let us now scrutinize this gibberish. 
         
1. The first line '#include<conio.h>". # is basically a directive for preprocessor. Before the compiler actually does it's 'thing', these statements pretending to be a bunch of smartass  get compiled beforehand.
2. '#include<stdio.h>" is another library function just like 'conio'. It contains 'printf' command. Without it, the compiler would display a prototype error.
3. Coming to the third line of this mystical sorcery, we encounter a rather strange spell 'int main()'. Main function is the point where the program begins its execution. (No, execution in this case does not stand for slaughter)
4.  The squiggly brackets '{' in line 4 and 6 basically represent the parameter for the code.
5. 'printf' command is used for displaying the output which in this case is... "Hola Muchahos!" (*Inserts Mariachi Music*). It is to be noted that ';' or semi colon is used to terminate the statements.
6 getch(); is basically used to hold the program execution. Without it, your program execution is going to ignore you like some fabulous chick.

How did it feel to treat a machine like your bottom chick? Now, let's talk about the advantages:

1. If this was a real chick, you'd have to spend a fortune on taking her out to a date just to make her utter "Hola Muchahos!"
2. You can do multiple programming, i.e. go out with dozens of droid chicks at the same time.
3. And on a lighter note, you can make her say "You're the Man!" just by editing a few words in the fifth line.


That's all for now folks. Remember: Syntaxberg says Relax.