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

Tutorial 8

This document contains 4 programming problems: 1) Write a program to produce a table of values using looping. 2) Write a program to count the number of 7s in a user-input integer. 3) Write programs to encrypt and decrypt 4-digit integers for secure data transmission. 4) Write a function to calculate the hypotenuse of a right triangle given the other two sides, and use it to calculate the hypotenuse of 3 sample triangles.

Uploaded by

dsssgd
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Tutorial 8

This document contains 4 programming problems: 1) Write a program to produce a table of values using looping. 2) Write a program to count the number of 7s in a user-input integer. 3) Write programs to encrypt and decrypt 4-digit integers for secure data transmission. 4) Write a function to calculate the hypotenuse of a right triangle given the other two sides, and use it to calculate the hypotenuse of 3 sample triangles.

Uploaded by

dsssgd
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Jaypee University of Information Technology

CI 101 Introduction to Computer Programming

Tutorial. 8

1. Write a program that utilizes looping to produce the following table of values:
A A+2 A+4 A+6
3 5 7 9
6 8 10 12
9 11 13 15
12 14 16 18
15 17 19 21

2. Write a program that reads an integer and determines and prints how many digits in the
integer are 7s.

3. A company wants to transmit data over the telephone, but they are concerned that their
phones may be tapped. All of their data is transmitted as four-digit integers. They have
asked you to write a program that will encrypt their data so that it may be transmitted
more securely. Your program should read a four-digit integer and encrypt it as follows:
Replace each digit by the remainder after (the sum of that digit plus 7) is divided by 10.
Then, swap the first digit with the third, and swap the second digit with the fourth. Then
print the encrypted integer. Write a separate program that inputs an encrypted four-digit
integer and decrypts it to form the original number.

4. Define a function called hypotenuse that calculates the length of the hypotenuse of a
right triangle when the other two sides are given. Use this function in a program to
determine the length of the hypotenuse for each of the following triangles. The
function should take two arguments of type double and return the hypotenuse as a double.
Test your program with the following values for sides :

Triangle Side 1 Side 2


1 3.0 4.0
2 5.0 12.0
3 8.0 15.0

You might also like