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

Introduction To Computing (GEL 103) Lab - Assignment 1 Deadline: 11 PM, 27.01.2016 Maximum Points: 10

This document provides instructions for a computing lab assignment to write a C program that takes two number bases and a number as input, checks if the number is valid for the first base, and if so converts it to the second base and prints the output. It specifies using scanf to read the input, considers the binary, octal, decimal and hexadecimal number bases, and provides example test cases and expected outputs. Students are to name their C file "base.c" and submit it by the given deadline following the detailed instructions on Moodle.

Uploaded by

Siddharth Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Introduction To Computing (GEL 103) Lab - Assignment 1 Deadline: 11 PM, 27.01.2016 Maximum Points: 10

This document provides instructions for a computing lab assignment to write a C program that takes two number bases and a number as input, checks if the number is valid for the first base, and if so converts it to the second base and prints the output. It specifies using scanf to read the input, considers the binary, octal, decimal and hexadecimal number bases, and provides example test cases and expected outputs. Students are to name their C file "base.c" and submit it by the given deadline following the detailed instructions on Moodle.

Uploaded by

Siddharth Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Introduction to Computing (GEL 103)

Lab Assignment 1
Deadline: 11 PM, 27.01.2016
Maximum Points: 10
Problem: Given two number bases b1, b2 and a number num, check whether num is a valid b1 base number. If yes, then convert the number num from number base b1 to number base b2 and print
the result, else print 0. You should consider the following four number bases:
1. Binary (base 2)
2. Octal (base 8)
3. Decimal (base 10)
4. Hexadecimal (base 16)
Write a C program to solve the above problem. Name the C file as base.c . To read the bases b1, b2
and number num, you need to use scanf. Please check the textbook or some on-line source for
details on the usage of scanf.
Test Cases:
:~$ b1 is: 2, b2 is: 10, num is: 10103
Output: 0, because 10103 is not a valid binary number.
:~$ b1 is: 2, b2 is: 10, num is: 1111
Output: 15
:~$ b1 is: 2, b2 is: 10, num is: 1001
Output: 9
:~$ b1 is: 10, b2 is: 2, num is: 4D2
Output: 0, because 4D2 is not a valid decimal number.
:~$ b1 is: 16, b2 is: 2, num is: 4D2
Output: 10011010010
:~$ b1 is: 8, b2 is: 10, num is: 109
Output: 0, because 109 is not a valid octal number.
:~$ b1 is: 8, b2 is: 10, num is: 107
Output: 71

Note: You should strictly follow the instructions given in the instruction file, which is available on
moodle.

You might also like