Saturday, March 25, 2023

OPERATOR AND OPERAND

   

OPERATOR AND OPERAND


In C programming, operators are symbols that perform various operations on operands. An operand, on the other hand, is a value or variable that is used in conjunction with an operator. Operators and operands are combined to form expressions, which are used to perform computations and manipulate data in a program.

Let's take a closer look at operators and operands in C:

  1. Operators: Operators in C can be classified into several categories based on their functionality. Some common types of operators include:

    • Arithmetic Operators: Perform basic arithmetic operations such as addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
    • Relational Operators: Compare the relationship between two operands and return a Boolean result. Examples include equal to (==), not equal to (!=), greater than (>), less than (<), greater than or equal to (>=), and less than or equal to (<=).
    • Logical Operators: Perform logical operations on Boolean values (true or false). These include logical AND (&&), logical OR (||), and logical NOT (!).
    • Assignment Operators: Assign values to variables. The assignment operator (=) is the most common example.
    • Increment and Decrement Operators: Increase (++) or decrease (--) the value of an operand by one.
    • Bitwise Operators: Perform operations at the bit level of operands. Examples include bitwise AND (&), bitwise OR (|), bitwise XOR (^), and bitwise NOT (~).
    • Conditional Operator: Also known as the ternary operator (?:), it provides a compact way to write conditional expressions.

  2. Operands: Operands are the values or variables on which operators act. They can take different forms, including:

    • Constants: Fixed values, such as numbers (e.g., 10, 3.14) or characters (e.g., 'A', '$').
    • Variables: Named storage locations that hold values.
    • Expressions: Combinations of operators and operands that result in a value.
    • Function Calls: Invoking a function can act as an operand, and the returned value can be used in expressions.

In C, operators and operands work together to perform computations and manipulate data according to the desired logic of the program. Understanding how to use operators and operands effectively is essential for writing correct and efficient C programs.

Sunday, March 19, 2023

Data Type

 DATA TYPE 

Definition

  1. It is a type of data which is used in the program.
  2. There are many predefined data types inc library like int, char, float, etc.  

Basic Type

Integer Type(int)

Floating Type(float)

Character Type(char)

Derived Type

Pointer

Array

Structure

Union

Integer Type  

Data Type

Size in bytes

Range

short

2

-32768 to +32767

int

2

-32768 to +32767

unsigned int

2

0 to 65536

long

4

-2147483648 to +2147483647

unsigned long int

4

0 to 4,294,967,295


Float Type

Data Type

Size in bytes

Range

float

4

3.4E-38 to 3.4E+38

double

8

1.7E-308 to 1.7E+308

long double

10

3.4E-4932 to 1.1E+4932


Character Type

Data Type

Size in bytes

Range

char

1

-128 to +127

signed char

1

-128 to -127

unsigned char

1

0 to 255


Saturday, March 11, 2023

Variables and Constant



VARIABLE

  Definition

  1. It is a name of storage space which is used to store data.
  2. It's value is changeable.
  3. It always contains last value stored to it.
  4. It is always declared with data type.
    Variable declaration
    
      int rollno;
      float marks;
      char grade;
    Here rollno is a variable of type int, marks is a variable of type float and grade is a variable of type char.

     Variable Initialisation
     
       int rollno=354;
       float marks=74.4;
       char grade='R';
     Here 354 is the value of rollno, 74.4 is the value of marks and R is the value of grade. Character value is always written in single quotes.
  
     Rules to declare a variable
  1. The first letter of a variable should be alphabet or underscore( _ ).
  2. The first letter should not be digit.
  3. After first character it may be a combination of letter or digits.
  4. Blank spaces are not allowed in variable name.
  5. Variable name should not be a keyword.
 

CONSTANT

     Definition
  1. An element of program whose value can not be changed at the time of execution of program is called constant.
  2. It is also called literals.
  3. It may be int, float and character data type.
      Rules for constructing integer constant
  1. It must have atleast one digit.
  2. It must not have decimal point.
  3. It may no be positive or negative.
  4. The range of integer constant is between -32768 to +32767.
  5. No comma or blank space are allowed in integer constant.
      Rules for constructing floating point constant
  1. It must have atleast one digit.
  2. It must have a decimal point.
  3. It may be positive or negative.
  4. No comma or blank space are allowed in floating point constant.
      Rules for constructing character constant
  1. It is a single alphabet, digit or special symbol.
  2. The length of character constant is 1 character.
  3. Character constant is enclosed within single qoutes (example:- 'A').
       Use of constants in program
      There are two ways of using constants in the C program.
  1. Using const
  2. Using #define
      Example
        
       int rollno=354;
       float marks=74.4;
       char grade='R';
      Here  354 is integer constant, 74.4 is float constant and R is character constant.
      
        

Saturday, March 4, 2023

C-Programming

 C-PROGRAMMING


C programming language is a powerful, high-level programming language that is widely used for developing system software, application software, and embedded software. It was developed in the 1970s by Dennis Ritchie at Bell Labs, and it has since become one of the most popular programming languages in the world. In this blog, we will cover the basics of C programming language.



  
      stdio
  1. It stands for standard input output.
  2. It is a collection of predefined function.
  3. It is also called library of C.
      include
  1. To include header file into program.
      #
  1. It is also called preprocessor.
  2. It includes the library of C into the program before the execution of program.
      conio
  1. It stands of console input output.
  2. It is used to show the output on console window.
      void 
  1. It is a keyword.
  2. It indicates that no one value is being returned by the function.
     main
  1. It is the function which is called the entry point of any program.
  2. The  execution of any program starts with main function.
  3. If in a program there is only one function then it should be main function.
      clrscr
  1. It stands for clear screen.
  2. It is a predefined function which is used clear the output screen.
  3. It acts like a duster in output screen.
  4. It is defined in conio.h header file.
      printf
  1. It is a predefined function which is used to print information or data on to the output screen.
  2. It is defined in the stdio.h header file.
      getch 
  1. It is a predefined function which is used to hold the output screen.
  2. It also acts like a duster on output screen.
  3. It is defined in the conio.h header file.

BITWISE OPERATOR

  BITWISE OPERATOR In C, bitwise operators are used to perform operations at the bit level of operands. They manipulate individual bits with...