What is the variables in c ?
Variable are the most important part of each programming language. variables are user defined. Here variable is the name of to the memory address. Where we store our data. Let's take example of Addition of two numbers : here we require two variables so suppose we taken variables name as 'num1' and 'Num2'. Also we require another variable to store result of Addition. That is 'result'.
Int num1; // first variable declared
Int num2; // second variable declared
int result; // third variable declared
result = num1 + num2 ; // added two numbers and Stored Addition in result.
When we print results using printf () function it shows result.
Basically we use variables for storing data and making process. Without variables programming is not possible. Because we require memory to store data. Because of that we use variables.
Hope you understood what is the variable and why it's require while programming.
How to print output on screen in c programming ?
C programming has standard libarary for I/o operations. That is " stdio.h" . This file give us access to use printf () function for displaying message on computer screen. Printf() is the function which is used for printing the message in screen. Using this function you can print output.
How to take input from user in c programming ?
C programming provides special function for input operation. That Function is ' scanf()". This function allows to take input or store input in variables.
For accessing Scanf () function we have to declared header file" stdio.h ". This file give us access to use Scanf () function.
What is the header file in c programming ?
Header files are most important for standard functions like input /output functions ex: printf (), scanf(), getchar(), gets(), puts() etc.
For accessing these functions we have to declare header file like
" #include < stdio.h >".
There are so many header files like stdio.h, conio.h,math.h,graphic.h, stdlib.h etc.
- header files declaration
- main function declaration.
- Start with opening & closing curly brackets.
- In between the opening and closing curly bracket add remaining body of code.
How to assign value to variable in c programming ?
When you declare variables or after declaration of variables you can assign value to the variable using assignment variables.
Here is example :
int number1; number1=20; Or int number1=20; It's works and easy.
1) Main function declaration
int main () { //Code body }2) variables declaration
int main() { // Data_type variableName ; int number1; }3) printf & scanf declaration
int main() {4) return statement declaration
int main() {what is the main() function ?
Each program in c start with main() function.
Main function is the starting point of execution of code. Without main() function we can't able to run c program. Because of this reason main() function is compulsory for each program.
see c program examples
Comments