A small program and input output

in GLOBAL STEEM3 years ago

christopher-gower-m_HRfLhgABo-unsplash.jpg

Let's write a small program first. The problem is that we will add two digits 4 and 5 using the programming language. Here we will use the C program.

You can think that to sum two small digits why should I write a large code? But you should also know that with the help of program coding a large number of calculations can be done within a second. Just like how your calculator works.

Al kinds of digital devices don't understand our language, they only understand coding languages.

Now, look at the below codings:
1 #include<stdio.h>
2
3 int main ()
4 {
5 printf ("%d/n", 4 + 5)
6 return 0;
7 }

Here the line 1: stdio.h is the header file that has been included. There are different types of header files in the coding world. This one works for the input and out. the word stdio stands for Standard input-output.

Line 2: is optional though. It's just for increasing the beauty of your coding😄

LIne 3: From here the main function has been started. When you will run the program in the compiler that time it will start functioning from here. It will take only integer numbers as input.

Line 5: Here the program is printing two digits. If you like to sum or subtract more digits at the same time individually then you have to write printf("%d %d\n", 4+5, 5-4) If you want to print any digit or number you always have to add %d
Again here printf works as output.

Line 6: The main function will always return 0 which means to end a program you always have to return 0 otherwise the program will not end and it will be an error.

To practice, you can try online compiler here C Compiler

Programing is really interesting. Just try at your home and see the fun. Thanks for reading my post.

Best regards
@shahriar33

Sort:  

thank you for sharing knowledge🙏🏻

I guess the saying practice make perfect is here now. Great post boss