Inputs and Outputs

The previous post explained about what C programming was, where it could be used, its advantages and its disadvantages. This post will explain what I first assimilated and coded. There are various libraries in C programming. First, there is ‘#include <stdio.h>.’ This system selects the library of tools that we are going to use. Second, ‘int main()’ represents to return the exit status which in this case is ‘return 0;.’ Third, there are brackets to show where the program is going to execute and terminate.

Finally, inside the brackets there is a command. An example of a simple command is ‘printf(“Hello, World!\n”);.’ Such code commands the computer to print whatever that was in the command to be presented on the screen. Combined altogether, the code sequence should look like something similar to below.

The first project I did involving the aforementioned concepts was a project that shows an input. First, make a space inside the memory for an input with ‘int a.’ ‘int’ is for integers only. Second, type in ‘printf(“Input a number\n”);.’ Then you use ‘scanf(“%d”, &a);’ to take in the input. Third, print your number with ‘printf(“your number is %d\n”, a);.’ Then it should look something like this.

To analyze the previous codes, ‘#include” <stdio.h>’ stands for the same thing, the library of tools, in the first paragraph. ‘int main ()’ also stands for the same thing, to return the exit status, in the first paragraph; the brackets are the execution and termination. ‘int a’ is an integer variable. ’printf(“input a number\n”);’ commands the computer to present ‘input a number’ on the screen, and ‘scanf(“%d”, &a);’ is a code that takes in the input. Inside the ‘scanf’, ‘%d’ means that the input will be a digit, and ‘&a’ shows that the input will be stored inside ‘a.’ ‘printf(“your number is %d \n”, a);’ shows that your number will be ‘%d’ a digit, and the value of the digit is ‘a.’ ‘return 0;’ is the return value to that returns it to ‘int main().’

The above explains the basic analysis of the program and its breakdown. Next post will explain ‘factorials’, ‘if’, ‘else if’ and ‘else.’