Sunteți pe pagina 1din 6

Q1) Write a program that requests from the user to enter a string then prints it backwards.

Example:

please enter a sentence: Hello what is your name?

?eman ruoy si tahw olleh

--------------------------------------------------------------------------------------------------------------------------------------

Q2) Write a program that requests the user to enter a number then check if its a prime number or
not?

Example:

1. please enter a number: 13


This is a prime number
2. please enter a number: 15
This is not a prime number

--------------------------------------------------------------------------------------------------------------------------------------

Q3) Write a program that requests the user to enter numbers then store them into an array then sorts
them from the smallest number to the largest number.

Example:

Enter the array of numbers: 6 4 8 59 33 12 44

the sorted array: 4 6 8 12 33 44 59

--------------------------------------------------------------------------------------------------------------------------------------

Q9) Write a program that requests from the user a string with one word then check if that word is the
same if flipped.

Example:

1. enter a word: sos


sos it is the same word
2. enter a word: baba
abab it is not the same word

--------------------------------------------------------------------------------------------------------------------------------------

Q16) Write a program that requests the user to enter a string. if the letters in the word are more than
or equal to 3 characters, it makes the first letter capital and all the letters in the strings small.

Example:

I WoUlD LiKe A cup oF tEe

I Would Like a Cup of Tee

--------------------------------------------------------------------------------------------------------------------------------------

Q17) write a program that converts an entered integer into a string without using the function strtod()
or any similar functions
Q7) Write a program that takes a number then prints a pyramid with rows equal to the entered
number.

Example:

1. please enter a number: 3

***

*****

2. please enter a number: 5

***

*****

*******

*********

--------------------------------------------------------------------------------------------------------------------------------------

Q5) Write a program that requests the user to input 3 values rows, columns and element then creates
a rows*column sized matrix with all its elements equal to element.

Example:

1. enter the dimensions: 2 3


enter the element: 8
the matrix is:
888
888
2. enter the dimensions: 3 3
enter the element: 23
the matrix is:
23 23 23
23 23 23
23 23 23

--------------------------------------------------------------------------------------------------------------------------------------

Q15) Write a program that continues to add all the digits of a number until it becomes a one digit
number.

Example :

Plese enter a number: 12346

12346 => 16 => 7

Please enter a number: 28049

28049=> 23 => 5
Q4) Write a program to calculate the result of summing two 3*3 matrices.

Example:

matrix1:

123

456

789

matrix2:

222

222

222

the result is:

345

678

9 10 11

--------------------------------------------------------------------------------------------------------------------------------------

Q6) Write a program to find the dot product of two vectors.

Example:

1. enter vector1: 1 1 1
enter vector2: 0 1 -1
the dot product is 0

2. enter vector1: 1 1 1
enter vector2: 2 2 2
the dot product is 6

--------------------------------------------------------------------------------------------------------------------------------------

Q10) Write a program that requests the user to enter a number then finds another number which is
the difference between its digits.

Example:

1. enter a number: 12325


the result is 1113
2. enter a number: 5555
the result is 0
3. enter a number: 227315
the result is 5424

--------------------------------------------------------------------------------------------------------------------------------------
Q14) Write a program that finds the numbers of words in a string that are greater than or equal a
requested input

Example :

Please enter a sentence : I am travelling to Istanbul.

Please enter a number : 3

The number of words greater than 3 is 2

Please enter a sentence : I am travelling to Istanbul.

Please enter a number : 1

The number of words greater than 1 is 5

--------------------------------------------------------------------------------------------------------------------------------------

Q8) Write a program that finds the distribution of the student marks in a class. the enter the number
of students first then find the distribution as shown below.

Example:

enter the number of students: 5

enter the grades:

Student 1: 87

Student 2: 68

Student 3: 94

Student 4: 100

Student 5: 83

Grade distribution:

0-9:

10-19:

20-29:

30-39:

40-49:

50-59:

60-69: *

70-79:

80-89: **

90-99: *

100: *
Q13) write a program that finds the prime factor of the number

Example

Please enter a number: 646

546 / 2

273 / 3

91 / 7

13 / 13

1
--------------------------------------------------------------------------------------------------------------------------------------

Q11) Write a program that takes two numbers then finds the bit-wise multiplication. if the result of
the multiplication is greater than 9 take the ones digit only.

Example:

1. first number: 12345


second number: 2222
the result: 4680
2. first number: 12345
second number: 2222
the result: 4680

--------------------------------------------------------------------------------------------------------------------------------------

Q12) Write a program that creates a unity matrix with a size selected by the user.

Example:

enter the size please: 3

the matrix:

100

010

001

--------------------------------------------------------------------------------------------------------------------------------------

Q16) Write a program that tells the user to enter a string then finds the different number of letters in
that string.

Example:

1. enter a string: yes, no maybe


the number of different letters is 8
2. enter a string: How are you today?
the number of different letters is 10
Q17) Write a program that finds the highest possible multiplication result between any two array
elements.

Example:

1. enter an array: 5 -9 8 3 -12 13


the highest possible multiplication result is -9*-12=108
2. enter an array: 1 2 3 4 5
the highest possible multiplication result is 4*5=20

--------------------------------------------------------------------------------------------------------------------------------------

Q18) Write a program that finds that takes two times in the HH:MM format then returns the difference
between them in minutes.

Example:

enter the first time: 12:00

enter the second time: 13:07

the difference in minutes is 67.

enter the first time: 23:50

enter the second time: 01:05

the difference in minutes is 75.

--------------------------------------------------------------------------------------------------------------------------------------

Q20) Write a program that requests from an integer then finds the result of the following equation:
1 1 1 1
= 1 +
2 3 4
using a recursive function.

S-ar putea să vă placă și