What is C Programming ?
C programming is a general purpose programming language and it is a machine independent language. C is in the fourth position In the Spectrum ranking. The founder of C is Dennis Richie and it was created from the “BCPL” and “B” programming languages. C initially became widely for the operating systems. C programming language is High Level Programming Language.
In the above image displayed the format of a simple C program. In the black area displayed the output. You can use repl.it , Atom , Eclipse CDT or the terminal in the fedora operating system.
Start Coding in C Programming
If you want to comment something, you can use // symbol to comment in a one line or you can starting from /* and ending it till */ for the multiple lines. Comment are used to document the programs to more user-friendly. Let’s think a program is coding by a team. You have a part in this program. After you finishing your part, next teammate start his part. If you comment your part to understand what this is, it will very important to other members to continue their parts. So keep going with comments.
Other part is header files. What are header file? Header files means “stdio.h” , “math.h” like wise. It is very helpful to process your program. starting from the # means processing before compiling the program. stdio.h means standard input/output library function.
Another one is main function. Every c program has the main function. because the program begins executing at main function. We can use “void” as a return type. But in void there is no return type. We can use “int” to return integer value.
Let’s see a simple C program.
01) First number is 35 and the second number is 20. Get the total and the average. After that print the values.
This is answer and its very big. It has 25 lines. Let’s code with the limited lines. You can use one line to create same type variables. for an example there are two variables called “no1” and “no2″. those two are integer type variables. you can create in a one line. It is ” int no1, no2; “. So let’s code with the limited lines.
See!!! It has only 17 lines. Let’s see the output in this program.
But there is an error in this program. The output says the average is 27. But it is wrong right? Because 55/2 = 27.5 . That because we assign our variable avg as integer. we must assign this variable as float or double. Yeah.. right!! I never told you that. Isn’t it? Okay let’s learn about variables.
Let’s learn Variables in C Programming
Variable is a location in the memory where a value can be stored for the user. When declaring a variable most importantly it must have a name and a data type. What are the data types? Integer, float, double, char are the data types and the variable name can assign any name. The format for declaring a variable is, data type first and the name should be the after the data type. For examples int sum, float average like wise.
In C, we must careful when the variable is declaring. Because C is a case sensitive language. It means you must careful about the uppercase and the lowercase. For an example, Sum, sum and SUM are three different variable names.
Other rules are variable may not be a reserved word ( ex- return, if, for… ), does not begin with a digit and variable may not contain a blank spaces( ex- wrong one is “int sum of the number” correct one is “int sumOfTheNumber” or “int Sum_of_the_number” )
Let’s see another example program.
01) Get the age from the user and print he/she is an adult or a child.( hint age >= 18, so he/she is an adult )
In here “scanf” is the method that we assign values, which we get from the user, to the relevant variable. If you want to get values from the user, use “scanf” keyword. In the below shows the output when you enter 10 for the age.
That’s all about the simple introduction of the C programming. Click here to learn advanced C programming. Don’t forget to leave a comment my failure things and share this to your friends. So see you in another post.
Thank you. This is the end of “C programming for beginners” article and make sure to leave a comment.
There are more articles from BuildITMasters. Follow the below link to refer.
- Selection Control Structure | C programming
- File Handling & Pointers | C programming – Click here to refer
- Repetition Structure in C programming
Other articles from different categories.
- Android Studio Articles – https://builditmasters.com/category/android-studio/
- Android Studio Firebase Tutorial – https://builditmasters.com/category/android-studio-firebase-tutorial/
- C Programming – https://builditmasters.com/category/programming/
- Flutter – https://builditmasters.com/category/flutter/
- GitHub Tutorials – https://builditmasters.com/category/github/
- Java Programming – https://builditmasters.com/category/java-programming/
- MERN / MEVN Stacks – https://builditmasters.com/category/mern_mevn_stacks/
- Tech News – https://builditmasters.com/category/tech-news/
- Theory Lessons – https://builditmasters.com/category/theory-lessons/
- Adobe Tutorials – https://builditmasters.com/category/adobe-tutorials/
- Best Website for Programming – https://builditmasters.com/category/best-website-for-programming/
- Different Programming Styles – https://builditmasters.com/category/different-programming-styles/
- Earn Money – https://builditmasters.com/category/earn-money/
- Social Word – https://builditmasters.com/category/social-world/
good job bro . all the best osanda .
Thank you very much