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

Assignment 06 Introduction To Computing Lab Report Template

This document contains C programs and algorithms for two questions. Question 1 asks to write a program to display a decimal number in octal notation. Question 2 asks to write a program that takes an integer input and displays the digits in words. The algorithms and programs contain steps to take input, reverse numbers, use modulo and division to extract digits and place them in the correct octal or word format, and print the output. Flowcharts and output screenshots are provided.

Uploaded by

1224 OZEAR KHAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Assignment 06 Introduction To Computing Lab Report Template

This document contains C programs and algorithms for two questions. Question 1 asks to write a program to display a decimal number in octal notation. Question 2 asks to write a program that takes an integer input and displays the digits in words. The algorithms and programs contain steps to take input, reverse numbers, use modulo and division to extract digits and place them in the correct octal or word format, and print the output. Flowcharts and output screenshots are provided.

Uploaded by

1224 OZEAR KHAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Introduction to Computing Lab (Batch-F3)

Assignment.No:06 Student ID: 211001001224


Name: OZEAR KHAN
Date: 13.03.2021

Aim:
Q1. Write a C program to display the
value of a decimal number in octal
notation.

Q2. Write a C program which will take


input as an integer number and will
echo the digits in words. (e.g. 123
should be ONE TWO THREE.)
Introduction to Computing Lab (Batch-F3)

Algorithm Q1:

(1) START.
(2) Declare variable n, oct, and i.
(3) Initialize oct and i.
(4) Print input statement for user.
(5) Take use input in variable n.
(6) Open a while loop until the variable n is greater than 0.
(7) oct=oct+(n%8) *i, to calculate octal of a decimal number.
(8) Divide the variable n by 8.
(9) Multiply i by 10.
(10) Print Octal Number
(11) STOP
Introduction to Computing Lab (Batch-F3)

Algorithm Q2:
(1) START.
(2) Declare variable n, rem, rev.
(3) Print input statement for user.
(4) Store user input in variable in n.
(5) Run a while loop until n is greater than zero.
(6) Reverse the user input number.
(7) And store the reverse number is the variable rev.
(8) Run a while loop until rev is greater than zero.
(9) Store the last digit of the rev number in the variable rem
(10) Open switch case along with 9 cases for each integer
from 1 to 9. And print in each cases the alphabets of that
integer. Break
(11) Default print alphabets of the number zero, break.
(12) STOP
Introduction to Computing Lab (Batch-F3)

Flowchart Q1:
Introduction to Computing Lab (Batch-F3)

Flowchart Q2:
Introduction to Computing Lab (Batch-F3)

Program Q1:
#include <stdio.h>
int main ()
{
int n,oct=0,i=1;
printf("Enter number in Decimal to convert it into Octal :");
scanf("%d",&n);
while (n>0)
{
oct=oct+(n%8)*i;
n=n/8;
i=i*10;
}
printf("Octal Number is : %d ",oct);
}
Introduction to Computing Lab (Batch-F3)

Program Q2:
#include <stdio.h>
int main ()
{
int n,rem=0,rev=0;
printf("Enter any number : ");
scanf("%d",&n);
while (n>0)
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
while (rev>0)
{
rem=rev%10;
rev=rev/10;

switch (rem)
{
case 1:
printf("One ");
break;
case 2:
printf("Two ");
break;
case 3:
printf("Three ");
break;
case 4:
Introduction to Computing Lab (Batch-F3)

printf("Four ");
break;
case 5:
printf("Five ");
break;
case 6:
printf("Six ");
break;
case 7:
printf("Seven ");
break;
case 8:
printf("Eight ");
break;
case 9:
printf("Nine " );
break;
default:
printf("Zero ");
}
}
}
Introduction to Computing Lab (Batch-F3)

Output Screenshot Q1:


Introduction to Computing Lab (Batch-F3)

Output Screenshot Q2:

You might also like