

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Various computer programming exercises from the csf111 course at birla institute of technology & science, pilani, india, during the first semester of the academic year 2019-20. The exercises cover topics such as number systems, variables, and datatypes. They include tasks like finding the power of binary numbers, writing c programs to accept user input and perform arithmetic operations, and formatting output.
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


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.