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

Programming Fifth Batch (String, Pseudocode Only) 45-55

Uploaded by

faiqakhaannn
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)
4 views

Programming Fifth Batch (String, Pseudocode Only) 45-55

Uploaded by

faiqakhaannn
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/ 5

The following programs are for the practice string processing and must be written in pseudocode only.

You may write them in python later but first only in pseudocode. You may use the built-in functions that
are given in the insert of 2022 June paper or Oct Paper.

Task # 45 : Input a string a print the following outputs one by one. Use For loop for the first 2, Repeat
Loop for the next 2 and While Loop for the last 2 patterns.

Suppose if the input string is "house"

(i)

h (iii) house (v) e

ho hous s

hou hou u

hous ho o

house h h

(ii) e (iv) house (vi) h

se ouse o

use use u

ouse se s

house e e

Task # 46 : Input a string and a character. Do not use find() method in this question.

(i) Find if the input character exist in the string.

(ii) Find the number of times the input character exists in the String.
Task # 47 : Input a Full Name and assume all characters input will be in lower case.

Write programs to print the given versions of the input name

for example if we enter "absar siddiqi"

your resultant string must be saved in a variable first then printed to convert an upper case to
lower case you can add 32 to its ascii code and subtract 32 for vice versa

(i) A. Siddiqi

(ii) Siddiqi, Absar

(iii) ABSAR

(iv) SIDDIQI absar

(v) Dr. A Siddiqi

Task # 48 : Input a string. You may assume that user will enter either upper case or lower case but all
characters will be the same. Your program should check and convert the string into uppercase if it is in
lowercase or convert to lowercase if it is in uppercase. using their ascii code. You cannot use the built-in
function to_lower() or to_upper(). You may use other functions given in the insert like lcase() and
ucase()

Task # 49 : Input a String and a character, remove all occurrance of the character from this String. for
example

"Co**mp*u******t*er"

"*"

"Computer"
Task # 50 : Input a Credit Card Number. Your program has to check the Validity of Credit Card Number
using Luhn Method and Length check.

First check the number is 16 digits long. If not it is not valid.

Then check the check-digit.

The check-digit is the last(16th) digit of the credit card number. This is how it works.

For example, in the card number 4578 4230 1376 9219, those digits would be:

4-5-7-8-4-2-3-0-1-3-7-6-9-2-1

Starting with the first digit, multiply every second digit by 2:

8-5-14-8-8-2-6-0-2-3-14-6-18-2-2

Every time you have a two-digit number, just add those digits together for a one-digit

result:

8-5-5-8-8-2-6-0-2-3-5-6-9-2-2

Finally, add all the numbers together:

8 + 5 + 5 + 8 + 8 + 2 + 6 + 0 + 2 + 3 + 5 + 6 + 9 + 2 + 2 = 71

When this number is added to the check digit, then the result must be an even multiple

of 10.

In this case:

71 + 9 = 80 [4374 5200 0946 1499]

The number is therefore valid. If the algorithm doesn't produce a multiple of 10, then

the card number cannot be valid. Write a program to validate an input Credit Card Number using the
above method given. You may use any built-in fucntion given in the insert.
Task # 51 : Input a String and print the check sum value of it. Check sum is the sum of Ascii Codes of all
charcaters. Divide the sum by 256, the remainder is the checksum.

Task # 52 : Input a HexaDecimal String. For Example "FA2B". Now convert this hex string to a denary
number.

16^3 16^2 16^1 16^0

4096 256 16 1

F A 2 B

(15 * 4096) + (10 * 256) + ( 2 * 16 ) + (11 * 1)

Task # 53 : Input a string and print whether it is a palindrome or not. Palindrome are the same when

reversed. for example madam, racecar, civic, radar, rotator etc

Task # 54 : Input the password from user. and check if it is valid or not. The following rules

must be followed in the password.

(i) at least 8 characters

(ii) Atleast one Lower case

(iii)At least one uppercase.

(iv) at least one digit

(v) at least one special character from the given list

{@,#,!,%}
Task # 55 : Input a string and a key value. The key must be between 1 to 25.

Encrypt the string and print the encrypted string. if the key is 3 then

a will be replaced by A + 3 = D

and X with A, Y wth B and Z with C.

every alphabet is replaced by another one dpending on the key value.

Plain Text Cypher Text

hello khoor

xyza abcd

Task # 56 : Input a range of years, and print how many years in this range have a repeated digit for
example 2012 has a repeated digit but 2013 doesn't.

The range will be input by the user. Print all the years you find to have repeated digits.

You might also like