VARIABLES EXAMPLE IN C LANGUAGE

Simple example to explain how variables are used.
Syntax:
int num;
float decimal;
char alphabet;
double number;
Here int, float, char and double are datatypes(type of data).
Here num,decimal,alphabet, number are variables. They may have any name.
Example describes getting two values from user and their addition .
#include<stdio.h>
int main()
{
int num1,num2;// Global declaration
printf("Enter the first number");
scanf("%d",&num1);
printf("Enter second number");
scanf("%d",&num2);
add(num1,num2);//Passing value to a  function "add()"
return 0;
}
void  add(int x,int y)
{
int total; // local variable
total = x + y; // performing actual addition
printf("The addition of two number is: %d",total); //Displaying addition of two numbers on screen
}
Output:
The addition of two number is: 5
Description:
Here we have used two types of variables.
1.Local variable (ex : total,x,y...)
2.Global variable (Ex: num1,num2)
We make those variable as global variable which we need to use throughout the code.
We make those variables as local variable which we would require very few times.
मराठीत वर्णन:
उत्तर:
The addition of two number is: 5
वर्णन:
इथे दोन प्रकारचे वरिअब्ले वापरले आहेत.
१.लोकाल वरिअब्ले
२.ग्लोबल वरिअब्ले.
लोकाल वरिअब्ले म्हणजे ज्यांना मर्यादित जागेतच वापरू शकत.
उधरणात: total ,x , y.
ग्लोबल वरिअब्ले म्हणजे ते वरिअब्लेस ज्यांना कोडच्या कुठल्या हि भागेत वापरू शकतो.
उधरणात: num1,num2.

Comments

Popular Posts