Notes
Notes
Notes
The output of bitwise AND is 1 if the corresponding bits of two operands is 1. If either bit
of an operand is 0, the result of corresponding bit is evaluated to 0.
Let us suppose the bitwise AND operation of two integers 12 and 25.
12 = 00001100 (In Binary)
25 = 00011001 (In Binary)
Bitwise OR operator |
The result of bitwise XOR operator is 1 if the corresponding bits of two operands are
opposite. It is denoted by ^.
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a>b
If a>c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b>c
Display b is the largest number.
Else
Display c is the greatest number.
Step 5: Stop
What is Programming?
Programming means creating a set of instructions for completing some specific
task. In the context of computing, programming means creating a set of
instructions not for a person but for a computer, in order to accomplish a specific
task. A computer requires programs to function. The program has an executable
form that the computer can use directly to execute the instructions. A collection of
computer programs and related data is referred to as the software. Computer source
code is typically written by computer programmers. Source code may be converted
into an executable file by a compiler and later executed by a central processing
unit. Alternatively, computer programs may be executed with the aid of
an interpreter.
Basic Programming Concepts
Even though each programming language you use is unique, there are certain
concepts common to all languages. Let's look at three of the most common
concepts and structures used in programming.
C Arithmetic Operators
An arithmetic operator performs mathematical operations such as addition, subtraction
and multiplication on numerical values (constants and variables).
* multiplication
/ division
remainder after
%
division( modulo division)
c = a+b;
printf("a+b = %d \n",c);
c = a-b;
printf("a-b = %d \n",c);
c = a*b;
printf("a*b = %d \n",c);
c=a/b;
printf("a/b = %d \n",c);
c=a%b;
printf("Remainder when a divided by b = %d \n",c);
return 0;
}
Output
a+b = 13
a-b = 5
a*b = 36
a/b = 2
Remainder when a divided by b=1
C Logical Operators
An expression containing logical operator returns either 0 or 1 depending upon whether
expression results true or false. Logical operators are commonly used in decision
making in C programming.
if (test expression)
The if statement evaluates the test expression inside the parenthesis ().
If the test expression is evaluated to true, statements inside the body of if are
executed.
If the test expression is evaluated to false, statements inside the body of if are
not executed.
if (test expression-2)
#include <stdio.h>
void main()
{ int number1, number2;
printf("Enter two integers: ");
scanf("%d %d", &number1, &number2);
if (number1 >= number2)
{
if (number1 == number2)
{
printf("Both are Equal”);
}
else
{
printf("Larger is- %d", number1);
}
}
else
{
printf("Larger is -", number2);
}
}
If the body of an if...else statement has only one statement, you do not need to use
brackets {}.