0% found this document useful (0 votes)
10 views

ICS Mid Assignment IP

The document provides instructions for three tasks: 1) Converting a binary number to octal, 2) Converting a hexadecimal number to binary, and 3) Drawing a flowchart for a C++ program to calculate the sum of the first 5 natural numbers.

Uploaded by

Tanjim Islam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

ICS Mid Assignment IP

The document provides instructions for three tasks: 1) Converting a binary number to octal, 2) Converting a hexadecimal number to binary, and 3) Drawing a flowchart for a C++ program to calculate the sum of the first 5 natural numbers.

Uploaded by

Tanjim Islam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Introduction to Computer Studies (Mid-Assignment)

1.(10111110)2 = (?)8 2. (EFA )16 = (?)2

3. Draw a flowchart from below C++ program to find the sum of first 5 natural numbers.

#include <iostream>
using namespace std;

int main() {
int sum;
sum = 0;
for (int i = 1; i <= 5; i++) {
sum =sum+ i;
}
cout << "Sum = " << sum << endl;
return 0;
}

(1)
Step 1: Divide the binary digits into groups of 3 starting from right.
010 111 110
Step 2: Converting every 3 binary digits (from bit0) to octal digit:

(010)2=0 x 22 +1 x 21+0 x 20=2


(111)2 =1 x 22 +1 x 21+1 x 20=7
(110)2=1 x 22 +1 x 21+0 x 20=6

Hence (010111110)2 = (276)8

(2)
Step 1: Divide the hexadecimal digits into 3 individuals starting from right.
EFA
Step 2: Converting each hex digits to binary digit:
(E)16=1110
(F)16 =1111
(A)16=1010

Hence (EFA)16 = (111011111010)2

Hex Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111

(3)
Flowchart of given code:

You might also like