Docsity

CSF111 Lab Session 6 - Computer Programming Exercises, Exercises of Computer Programming

Toggle sidebar
bg1
BIRLA INSTTUTE OF TECHNOLOGY & SCIENCE, PILANI (RAJ.)
First Semester 2019-20
CS F111 Computer Programming
LAB SESSION #6
(Number Systems, Variables and Datatypes)
1. Find the solution to the following
a. (110 110 000)2 = ( ? )8
b. (1000 1100 0000 1100)2 = ( ? )16
c. (0011.10111)2 = ( ? )10
d. (123)8 = (? )10
e. (ABCD)16 = ( ? )10
f. (12.3)8 = ( ? )10
g. (ABCD)16 = ( ? )8
h. (98.7)8 = ( ? )16
i. (12.45)10 = ( ? )2
j. (0 10001001 1100000000000000000000) in FP = ( ? )10
k. (134.50)10 = ( ? ) in FP using 32 bit
2. Write a C program that accepts a character input and an integer value as the key.
Add the key to the ASCII value of the character and print the equivalent character.
3. Write a C program to determine the sum of the following sequences
a. Arithmetic sequence
๐‘†๐‘›= ๐‘›
2[2๐‘Ž1+(๐‘› โˆ’ 1)๐‘‘] where n is the number of terms, ๐‘Ž1 is the first term and
d is common difference.
b. Geometric sequence
๐‘†๐‘›= ๐‘Ž1(1โˆ’๐‘Ÿ ๐‘›)
1โˆ’๐‘Ÿ where n is the number of terms, ๐‘Ž1 is the first term and r is
common ratio.
Solve the following problems using formatted input and/or formatted output only.
4. A C program contains the following statements
#include <stdio.h>
char text[] = โ€œThis is C Programmingโ€;
Write a printf() function that will allow the contents of text to be displayed in the
following ways.
a. Entirely on one line.
b. Only the first eight characters.
c. Only the first eight characters, preceded by five blanks.
d. Only the first eight characters, followed by five blanks.
pf2

Partial preview of the text

Download CSF111 Lab Session 6 - Computer Programming Exercises and more Exercises Computer Programming in PDF only on Docsity!

BIRLA INSTTUTE OF TECHNOLOGY & SCIENCE, PILANI (RAJ.)

First Semester 2019-

CS F111 Computer Programming

LAB SESSION # (Number Systems, Variables and Datatypes)

1. Find the solution to the following a. (110 110 000)2 = (? ) 8 b. (1000 1100 0000 1100) 2 = (? ) 16 c. (0011.10111) 2 = (? ) 10 d. (123) 8 = (? ) 10 e. (ABCD) 16 = (? ) 10 f. (12.3) 8 = (? ) 10 g. (ABCD) 16 = (? ) 8 h. (98.7) 8 = (? ) 16 i. (12.45) 10 = (? ) 2 j. (0 10001001 1100000000000000000000) in FP = (? ) 10 k. (134.50) 10 = (? ) in FP using 32 bit 2. Write a C program that accepts a character input and an integer value as the key. Add the key to the ASCII value of the character and print the equivalent character. 3. Write a C program to determine the sum of the following sequences

a. Arithmetic sequence ๐‘†๐‘› = ๐‘› 2 [2๐‘Ž 1 + (๐‘› โˆ’ 1)๐‘‘] where n is the number of terms, ๐‘Ž 1 is the first term and d is common difference. b. Geometric sequence ๐‘†๐‘› = ๐‘Ž^1 (1โˆ’๐‘Ÿ

๐‘›) 1โˆ’๐‘Ÿ where n is the number of terms,^ ๐‘Ž^1 is the first term and r is common ratio.

Solve the following problems using formatted input and/or formatted output only.

4. A C program contains the following statements #include <stdio.h> char text[] = โ€œThis is C Programmingโ€;

Write a printf() function that will allow the contents of text to be displayed in the following ways. a. Entirely on one line. b. Only the first eight characters. c. Only the first eight characters, preceded by five blanks. d. Only the first eight characters, followed by five blanks.

5. Write a C program that gets the date as dd/mm/yyyy (Note: the input should be provided in the specified format. For eg. type 05/03/2019 as input) and prints it as mm-dd-yyyy. 6. Write a program to read the name ANIL KUMAR GUPTA in three parts using the scanf statement and to display the same in the following format using the printf statement. (a) ANIL K. GUPTA (b) A. K. GUPTA (c) GUPTA A. K.