Professional Documents
Culture Documents
Bessala Laurene Justine
Bessala Laurene Justine
MATRICULE :ET20200473
COMPUTER ASSIGNEMENT
1.What is the difference between Time complexity and space complexity
Time complexity of an algorithm quantifies the amount of time taken by an algorithm to run
as a function of the length of the input. Similarly, Space complexity of an algorithm
quantifies the amount of space or memory taken by an algorithm to run as a function of the
length of the input .
.Precise
.Definiteness
.Effectiveness
. Finiteness
.Independent
4: Pseudo-code #include<stdio.h>
input Number1,Number2,Number3 :Real void main()
{
Begin
int a[5],i,j,c;
if(Number1 < Number2) then
clrscr();
if(Number1 < Number3) then printf("Enter five no. :");
display "Num1 is the smallest" for(i=0;i<=4;i++)
else {
display "Num3 is the smallest" o scanf("%d",&a[i]);
}
end-if
o for(i=0;i<=4;i++)
else if(Number2 < Number3) then o {
display "Num2 is the smallest" for(j=i+1;j<=4;j++)
else {
display "Num3 is the smallest" if(a[i]>a[j])
{
end-if
c=a[i];
End . a[i]=a[j];
a[j]=c;
} }
} printf("\n");
o } getch();
for(i=0;i<=4;i++) }
{
printf("%d",a[i]);
6 . #include <stdio.h>
int main() {
int n, i, flag = 0;
scanf("%d", &n);
if (n % i == 0) {
flag = 1;
break;
if (n == 1) {
else {
if (flag == 0)
else
}
return 0;
7. #include <stdio.h>
int main() {
int num;
scanf("%d", &num);
return 0;
8. ALGORITHM
Step 1. Start
3.1.3: Stop
3.1.4: i = i + 1
Step 4. Else:
Step 5. Stop
C PROGRAM
#include <stdio.h>
#include <math.h>
/*function definition*/
int iVar;
float fVar;
fVar=sqrt((double)number);
iVar=fVar;
if(iVar==fVar)
return 1;
else
return 0;
int main()
int num;
scanf("%d",&num);
if(isPerfectSquare(num))
else
return 0;
9. #include<stdio.h>
int main()
{
int num;
scanf("%d",&num);
if(num%i==0)
printf("%d\t", i);
return 0;
int main()
int i, Number;
scanf("%d", &Number);
if(Number%i == 0)
}
}
return 0;
11. #include<stdio.h>
#include<conio.h>
void main()
getch();
5.1 fact=fact*i
5.2 i=i+1
Step 7: Stop
#include <stdio.h>
int main() {
int n, i;
scanf("%d", &n);
if (n < 0)
else {
fact *= i;
return 0;
int main() {
int n, i;
scanf("%d", &n);
return 0;
int main() {
int i;
n=4
return 0;
Get the rightmost digit of the number with help of the remainder ‘%’ operator by dividing it by 10
and add it to sum.
Divide the number by 10 with help of ‘/’ operator to remove the rightmost digit.
// number.
#include <stdio.h>
int getSum(int n)
int sum = 0;
while (n != 0) {
n = n / 10;
return sum;
// Driver code
int main()
{
int n = 687;
return 0;
21. #include<stdio.h>
void main()
int a[5],i,j,c;
clrscr();
for(i=0;i<=4;i++)
scanf("%d",&a[i]);
for(i=0;i<=4;i++)
for(j=i+1;j<=4;j++)
if(a[i]>a[j])
c=a[i];
a[i]=a[j];
a[j]=c;
}
for(i=0;i<=4;i++)
printf("%d",a[i]);
} printf("\n"); getch();
22. Algorithm
#include <stdio.h>
// otherwise -1
if (r >= l) {
int mid = l + (r - l) / 2;
// itself
if (arr[mid] == x)
return mid;
if (arr[mid] > x)
// in right subarray
return binarySearch(arr, mid + 1, r, x);
// present in array
return -1;
int main(void)
int x = 10;
result);
return 0;