Bca (B3) Pds Assignment Harshit Singh Chauhan SAPID: 500097391
Bca (B3) Pds Assignment Harshit Singh Chauhan SAPID: 500097391
QUESTION 1:
Flowchart is a graphical representation of an algorithm. Programmers often use it as a program-
planning tool to solve a problem. It makes use of symbols which are connected among them to
indicate the flow of information and processing.
The process of drawing a flowchart for an algorithm is known as “flowcharting”. Uses of
flowchart,
= 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
Relational operator-
A relational operator checks the relationship between two operands. If the relation is true, it returns
1; if the relation is false, it returns value 0.
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.
Operator Meaning Example
Logical AND. True only if all If c = 5 and d = 2 then, expression ((c==5) &&
&&
operands are true (d>5)) equals to 0.
Logical OR. True only if either one If c = 5 and d = 2 then, expression ((c==5) ||
||
operand is true (d>5)) equals to 1.
Bitwise Operators-
During computation, mathematical operations like: addition, subtraction, multiplication, division,
etc are converted to bit-level which makes processing faster and saves power.
| Bitwise OR
^ Bitwise exclusive OR
~ Bitwise complement
Arithmetic Operators-
* multiplication
/ division
n=2;
while(n<=last)
{
printf(" %d",n);
n=n+2;
}
n=1;
while(n<=last)
{
printf(" %d",n);
n=n+2;
}
getch();
QUESTION 4:
#include<stdio.h>
int power(int a, unsigned int b)
{
if (b == 0)
return 1;
else if (b%2 == 0)
return power(a, b/2)*power(a, b/2);
else
return a*power(a, b/2)*power(a, b/2);
}
int main()
{
int a = 2;
unsigned int b = 3;
printf("%d", power(a, b));
return 0;
}