Sum of N terms in Harmonic series:
Given integer N as input, write a program to display the sum of the first N terms in harmonic series. The series is: 1 + 1/2 + 1/3 + 1/4 + 1/5 ... + 1/N (N terms).
The first line of input is an integer N.
Output
Print the sum rounded up to 2 decimal places.
For
N = 5The sum of first 5 terms in harmonic series is 1 + 1/2 + 1/3 + 1/4 + 1/5
So, the output should be
2.28.
Sample Input 1
5
Sample Output 1
2.28
Sample Input 2
3
Sample Output 2
1.83
A continue statement is used in an iteration control to skip the remaining statements in the loop and proceed with the next iteration of the loop
Write a c++ program that create a one dimensional array with of length5.your program should read 5 integers from the keyboard into the array. Your to perform sequential search for an integer in the array and insert a new item in that location of the array.
Diamond Crystal
Given an integer value N, write a program to print a diamond pattern of 2*N rows as shown below.
Input
The first line of input is an integer N.
Explanation
In the given example, the number of rows in the diamond is
2*5 = 10.So, the output should be
/\
/ \
/ \
/ \
/ \
\ /
\ /
\ /
\ /
\/
Sample Input 1
5
Sample Output 1
/\
/ \
/ \
/ \
/ \
\ /
\ /
\ /
\ /
\/
Sample Input 2
3
Sample Output 2
/\
/ \
/ \
\ /
\ /
\/
There is a structure called employee that holds information like employee code, name, date of joining. Write a program to create an array of the structure and enter some data into it. Then ask the user to enter current date. Display the names of those employees whose tenure is 3 or more than 3 years according to the given current date.
The game is played as follows:
The game consists of 3 turns, and the aim of the game is to score as many points as possible,Each turn begins with a roll of 6 standard dice,Matching dice (2 or more of the same number) can be set aside for points, and the remaining dice can then be re-rolled in an attempt to score more points 5s Points are “amount of dice * number on dice”, e.g. rolling three 5s is worth 15 points,The player chooses whether to set matching dice aside and whether to re-roll remaining dice, If the player chooses not to re-roll the dice, the points accumulated in the turn are added to their score and the turn ends, If no dice can be put aside after a roll, the player loses the points the potential points and the turn ends – hence, the player must decide how far to push their luck with additional rolls,The game involves quite a lot of luck, but there is also a small amount of strategy in choosing whether to set matching dice aside and whether to re-roll the remaining dice.
Two Words Combination
Given a sentence as input, print all the unique combinations of two words in lexicographical order.Input
The input will be a single line containing a sentence.Output
The output should be multiple lines, each line containing the unique combination of two words in lexicographical order.Explanation
For example, if the given sentence is "raju plays cricket", the possible unique combination of two are (cricket, plays), (cricket, raju), (plays, raju). So the output should be
cricket plays
cricket raju
plays rajuSample Input 1
raju plays cricket
Sample Output 1
cricket plays
cricket raju
plays raju
Sample Input 2
python is a programming language
Sample Output 2
a is
a language
a programming
a python
is language
is programming
is python
language programming
language python
programming python