Friday, 15 December 2017

Operators In C

Operators In C

operators in c


operators in c refers to the symbols which are used to perform mathematical operations in c programming. Operators  are nothing but the specific symbols which is used to perform mathematical operations in the program.

Programming c is very rich in operators. We can perform all type of mathematical operations in c. for that it provides wide range of c operators.


C programming provides following type of different operators-


  1. Arithmetic Operators
  2. Relational Operators
  3. Assignment Operators
  4. Logical Operators
  5. Increment and Decrement Operators               
  6. Bitwise Operators
  7. Special Operators


C Arithmetic Operators

In c arithmetic operators are used to perform basic type of mathematical operations such as addition,subtraction,multiplication ,division etc. these operators are mostly use in the programs.
Following table shows the arithmetic operators and their use with example.


Operator
Use
Example
+
Addition
2+2=4
-
Subtraction
2-2=0
*
Multiplication
2*2=4
/
Division
2/2=1
%
Reminder
2%2=0


C Relational Operators


Relational operators are used to  check the relation between two operands. relations such as  less than,greater than, equals to,etc. these operators are mostly used in decision making statements.

operator
Use
Example
< 
Returns true if value is smaller than comparing value
4<2     returns false
2<8     returns true
> 
Returns true if value is bigger than comparing value
8>2     returns true
5>10   returns false
<=
Returns true if value is less or equal  to the given value
2<=5   returns true
6<=3   returns false
5<=5   returns true
>=
Returns true if value is greater or equal to the given value
8>=8   returns true
5>=6   returns false
10>=6  returns true
==
Returns true if two values are same
10==10 returns true
6==5     returns false
!=
Returns true if given value is not equal to comparing value
10!=10  returns false
10!=50 returns true

Assignment Operator

Assignment operators are used to assign values to the variables. Following table shows the various assignment operators in c.


Operators
   Example
equals
=
a = b
a = b
+=
a += b
a = a+b
-=
a -= b
a = a-b
*=
a *= b
a = a*b
/=
a /= b
a = a/b
%=
a %= b
a = a%b
<<=
C <<= 2
is same as C = C << 2
>>=
C >>= 2
is same as C = C >> 2
&=
C &= 2
is same as C = C & 2
^=
. C ^= 2
is same as C = C ^ 2
|=
C |= 2
is same as C = C | 2


Increment and decrement operators



Increment and decrement operators are used to increase and decrease value of variables by 1 respectivly. following table shows details about increment and decrement operators.


operator
Use
Example
++
Increase value of variable by one
a++
--
Decrease value of variables by one
a--

Logical operators

Logical operators are used to check the conditions. It returns  0 or 1 depending upon condition become true or false. Suppose a=0 and b=1


Operator
Description
Example
&&
It returns true if given all conditions are become true
(a && b) is false.
||
It returns true if any one condition becomes true
(a || b) is true.
!
It converts true to false and false to true
!(a && b) is true


Bitwise operator



Bitwise operators works on bit level. They perform calculations on bit level. Following table shows the detail information about bit level operators.


Operators
Meaning
&
Bitwise AND
|
Bitwise OR
^
Bitwise exclusive OR
~
Bitwise complement
<< 
Shift left
>> 
Shift right


specail operators

Following are some important operators which are very important in c. they are used for different purposes these operators shown in following table.

Operators
meaning
Example
sizeof()
Returns the size of a variable.
sizeof(i), where i is integer, will return 4.
&
Returns the memory address of a variable.
&b; returns the actual address of the variable.
*
Pointer to a variable.
*b;
? :
Conditional Expression.
If Condition is true then it returns first value otherwise second value  will be return




Check Aadhaar & Bank Account Link Status

Here we will discuss about how to know that Aadhaar number is linked with bank account or not.

Check Aadhaar & Bank Account Link Status

The Central Government has made the mandatory for opening of bank accounts and all old accounts.

This notification was issued by the government on June 1.

The last date for linking Aadhaar with bank accounts is 3 March 2017.
If you do not link your Aadhaar number to bank accounts then the operation of your bank account may be discontinued.

Let's know how to know whether your bank account status, whether it is linked to that base or not.

Check Aadhaar & Bank Link Status:

 Step 1- Visit the Aadhaar website https://uidai.gov.in/

Step 2. Click on 'Check Aadhaar & Bank Account Linking Status'. Or click here https://resident.uidai.gov.in/bank-mapper

 Step 3. Enter the Aadhaar number and security code.

enter aadhaar number

Step 4. A One Time Password (OTP) will appear on your mobile number.
Insert OTP and click Login.

5- After the login, a page will open in front of you on the website, on which you will be able to see if your Aadhaar number is linked to the bank account or not.

If you do not want to go to Aadhar's website then you can also know the status of your mobile.

Let's know how to find out.

Remember that the mobile number must be linked to the bank account.
1: Dial * 99 *99 *1 # from your mobile
2- Enter the 12 digit Aadhaar number.
3- Make sure that the Aadhaar number that is written on your behalf is absolutely correct.  Confirm by replying 1

aadhar and bank link status

4- After this you will know whether your bank account is linked with the Aadhaar or not.

Note :
When you know about the status of linking your bank account and the Aadhaar, you have to take care of some things. 

The first thing is that in this you will only see that account number, which you have linked to the last one.

If you have many bank accounts, then you have to contact the bank for other accounts.


Wednesday, 13 December 2017

C Constants

c constants

C Constants

C constants are nothing but the one type of variables which values cant be change during the program execution. C constants  treat like variables but key difference is that its value doesn’t change.
Like variables c constants can be of many data types such as int,float,char etc.

C defines  some rules to define constants these are given below-

Rules to for naming c constants:


  1. A constants name can have any letters , digits and underscore .
  2. The first letter of constants must be  a letter .
  3. Generally It is good programming  to type constants name in upper case(capital letters). But however there is no restriction to type in uppercase.
  4. Upper case and lower case treated as different. It is case sencetive.

In c we can define constants in many ways. These are given below

Defining constant using const Keyword:

By using const keyword we can declare constant. Const keyword is used as prefix,

Syntax

[
const data type  constant_name;
]

for example:




#include <stdio.h>
int main() {
   const int  NUMBER1= 20;
   const int  NUMBER2 = 10;
   const char NEW_LINE = '\n';
   int addition;
 
   addition = NUMBER1+NUMBER2;
   printf("addition is : %d", addition);
   printf("%c", NEW_LINE);
   return 0;
}


Output:

Addition is:30

Defining constant using #define

In c it is an also simplest way to define constant using the #define keyword. This type of constant doesn’t need to declare their data type. The are declared after the declaring header files.

Syntax:

[
#define constant_name value

]

For example:

[
#include <stdio.h>

#define NUMBER1 10  
#define NUMBER2  20
#define NEW_LINE '\n'

int main() {
   int addition; 
 
   addition=NUMBER1+NUMBER2;
   printf("Addition is : %d", addition);
   printf("%c", NEW_LINE);

   return 0;
}

]

Output:

Addition is:30


Literals:

Following are the different literals which can be used as constants.

1. Integer literals

Integer literals are the literals which only stores the numerical values without any floating point.integer literals are of three types:

  • decimal literals:  decimal literals means which numbers has base 10. For ex. 22,-9 25 etc.
  • octal literals:   octal literals having base 8. These literals start with 0. For ex. 0236,023,014 etc.
  • hexadecimal  literals:  hexadecimal literals hiving base 16.  These literals start with 0x or 0X.

2. Floating-point literals

A floating point literal is nothing but numeric value that has either a fractional form or an exponent form. For example:

-5.7
0.0000934
-0.32E-5

3. Character literals

A character literal is nothing but  constant which having single quotation around single character. For example: 'M', 'l', 'Y', 's'

Enumeration constants

 This is another most important type of constants in c.enum keyword is used to define enumeration types constants .

 For example:

enum colors {yellow, blue, black, pink};

Here, colors is a variable  of enumeration type and yellow, blue, black, pink are the enumeration constants having value 0, 1, 2 and 3.

               





Friday, 8 December 2017

Addition Program In C


c addition program is a very basic program in c. addition program in c refers to an addition of  numbers. in this program user will enter any two number of their choice and program returns sum of that two numbers as output.


C Addition Program


#include<stdio.h>
#include<conio.h>
Void main()
{
int num1,num2;          
int sum;
printf(“Enter First Number:”);
scanf(“%d”,&num1);
printf(“Enter Second Number:”);
sum=num1+num2;
printf(“Addition Of Entered Two Numbers Is:%d”,sum);
getch();
}

Output:

Enter First Number:10

Enter Second Number:20

Addition Of Entered Two Numbers Is:30

Explanation:

In above program

#include<stdio.h>
#include<conio.h>

In first two lines contains the header files. Header files are nothing but the  libraries of c programming. 

Inbuilt functions and features which are we using in program such as printf(),scanf(),getch() etc are defined in these header files.

 If you doesn’t include these header files write program you got error messages. These function cant work without including header files.

void main() :

 this is the main function of c programming. Program execution starts from here. Void is the return type of main function. 

It may be change such int main(), void return type means it doesn’t return anything so void is defined as return type of main ().

int num1,num2: 

int this line we declare two variables of int type num1 and num2 respectively. These two variable accepts integer numbers in run time user enters.

int sum:

In this line we declare sum variable of int type to store the addition of above two variables num1 and num2. The variables num1 and num2 are type of int so that their addition also of int type so we declare sum variable as int type.

printf():

printf() will print the message on the screen which is mentioned int the double inverted quo ma in brackets.

Scanf():

scanf() function is used to store data in variables at  run time. It accepts value from user at run time. If users enter valid value same as data type it accept it and store in that particular variable.

Sum=num1+num2:

In this line program performs addition of num1 and num2 variables and it assign it to the variable sum.

Getch():

This function hold the screen. This function is defined in  #include<conio.h>


Wednesday, 6 December 2017

Variables In C

Variables In C

In simple words we can say that c variable is nothing but the name given to the memory location in which we can store data for the manipulations. Every c variable has a specific data type which determines what type of data is to be stored in specific variable and what should be a range of it.
  c variables value may be change during the program execution. Variables in c belongs to the any data type such as int,float,char,double etc.

Rules for declaration of variables

1.     Variable name must begin with letter or underscore.
2.     Variable name is case sensitive.
3.     We can use any numbers and letters in variable name.
4.      Special symbols are not allowed escape underscore (_) in variable name.

Defining variable:

Variable definition means the allocation of memory for the variable. Before using the variable it should be defined. So the system assigns the memory for that specific variable according to the data type of variable.

Syntax:

[
Data Type  var_name1,var_name2….var_nameN;

Data type- it refers to data type of variable such as int,char,float etc.
var_name1,var_name2….var_nameN- refers to an variable list. We can declare any number of variables.
Example:
int a,b;
char ch;
float n;
]

Assigning values to variables:

Assign values to the variables means storing data into the reserved memory location by the variables. Variables can be assigned at the time of definition and in the program also.

Assigning variable at the time of definition

[

int a=10;
char ch=’a’;
]

Assigning value in the program

[

#include<stdio.h>
int main()
{
int a,b,c;    //defining variabe
a=10;          //assigning value 10 to variable a
b=20;       //assigning value 20 to variable b
c=a+b;        //assigning addition of variable a and b to the c
printf(“Addition of a and b is:%d”,c);
return 0;
}
]

What is the lvalue and rvalue?

Generally we listen about rvalue and lvalue in programming, many of those can’t understand what is actual what is rvalue and lvalue.
Lvalue: lvalue always refers to a memory location. It points to memory address. It may be on left hand side and right and side also. Variables are comes into this categories.
Rvalue: rvalue always refers to numeric values. It always present on right hand side but not left hand side. Rvalues always assigns to variables. Values cant be assign to rvalues.

[ A       =      10
Lvalue   rvalue
]


 Previous Page                                                                                                                   Next Page