Professional Documents
Culture Documents
Variables
Variables are analogous to Buckets or
Data Types
Data types tell about what type of value our
Assignment Operator
Assignment operator = is used to assign
value to a variable
Beware not used this == be cause it is
equality operator it checks the equality
between variable name and value assigned to
it.
Syntax will be
Data type variable name assignment
operator value
Variable Names
It is up to you what name you give to your variables
For examples
Int number=10;
First DATA TYPE is INT as it only accept integer which is
10
Second name of our variable is NUMBER name could be
anything here I used Number you can use your name
also
Third Assignment operator we give our variable
Number a value so after this
Number=10 our variable number can store an integer
number 10.
Some Examples
Int number=10;
Int bob=20;
Int khan=30;
Float num=10.87;
Float numbe=10.8;
Double num1=10.2321;
Double khan=10.43434;
Some Examples
Char
Char
Char
Char
Char
name=c;
ali=d;
sign=+;
bob=-
mult=*;
Comments
Always use comments it is good programming
pratice
The benefit of commenting is that some one
who sees your code can easily understand it
For comments use
//this is my prog//
Compiler can execute your programme line by
line and ignore the comments line it does not
effect your programme performance
Use //I am a commnet//
Simple Example
In C++
#include<iostream>
using namespace std;
int main()
{
int
number=10,number1=20,add;//in
itialize variable and assign
values//
add=number+number1;//result of
these will be stored in add//
cout<<add;//for displaying//
}
Thanks to Devc++
In Java
public class JavaApplication6 {
/**
* @param args the command line
arguments
*/
public static void main(String[] args) {
int number=10,number1=20,add;
add=number+number1;
System.out.println(add);
}
}
Thanks to netbeans
Thanks alot
Contact me at
muhammadhaseeb562@g
mail.com
Mobile no:0336-5686312