first letters
you are given three strings are inputs. write a program to print the first character of each string.
input
the first,second and third lines of input are strings.
explanation
consider the given strings to be apple, banana and carrot.we need to consider the first character in each of these strings we get the character a from the string apple. we get the character b from the string banana. we get the character c from the string carrot. so the final output should be abc
sample input 1
apple
banana
carrot
sample output 1
abc
sample input 1
very
important
person
sample output 2
vip
compare last three characters
write a program to check if the three last characters in the given two strings are the same
input
the first and second lines of inputs are strings
output
the output should be either true or false
explanation
given strings are apple ,pimple. in both strings, the last three characters ple are commom
so the output should be true.
sample input 1
apple
pimple
sample output 1
true
sample input 2
meals
deal
sample output 2
faslse
Implement a class Sequence to store a sequence of non-negative integer values, and the length
of the sequence. The class has the following private data members:
1. int length – the length of the sequence
2. int *pseq – a pointer to a dynamic integer array holding sequence of integers
The class shall provide the following public methods:
1. Sequence() – a default constructor that initializes length to 10 and store the sequence of
all zeros in an array.
2. Sequence(int lengthVal, int n1=0,int n2=0,int n3=0, int n4=0, int n5=0, int n6=0, int n7=0,
int n8=0, int n9=0, int n10=0) – another parameterized constructor should initialize the
length and array to sequence values passed in the arguments.
3. Sequence(Sequence &s) – a copy constructor that creates a copy of a Sequence object.
4. int getLength() – a getter for length
5. int* getSeq() – a getter for the sequence of numbers
6. void Sort(int n) – a function that sorts the first n elements in the sequence array. You
cannot use Bubble Sort Algorithm
Implement a class Matrix to create matrices of 2x2, 3x3 and 4x4 with the following private data members:
1. int **matrix – a double pointer of type integer to create a 2D array (matrix)
2. int row – an integer to store the rows in the matrix
3. int col – an integer to store the columns in the matrix
The class shall have the following public member functions:
1. Matrix (int n1, int n2, int n3, int n4, int row = 2, int col = 2) – a parametrized
constructor for a 2x2 matrix
2. Matrix (int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int row = 3,
int col = 3) – a parametrized constructor for a 3x3 matrix
3. Matrix (int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int
n11, int n12, int n13, int n14, int n15, int n16, int row = 4, int col = 4) – a
parametrized constructor for a 4x4 matrix
4. Matrix(const Matrix &m) – a copy constructor
5. ~Matrix() – a destructor
6. int getRow() – a getter for rows
7. int getCol() – a getter for columns
Implement a structure, Car. The structure has the following data member:
1. int petrolLevel – that indicates the liters of petrol in the car’s petrol tank. PetrolLevel for
this car can only be in the range 0 – 45 liters.
The structure has the following member functions:
1. void setPetrolLevel(int petrolLevelVal) – a setter for petrol level, cannot set value greater
than 45.
2. int getPetrolLevel() – a getter for petrolLevel
3. Car() – a default constructor
4. Car(int petrolLevelVal) – a parametrized constructor
5. bool MoveCar(int distanceKM) – a function that takes an integer as an argument and
moves the car to the argument value which is in Km. Provided the petrol tank has enough
fuel. Successful movement of the car returns true otherwise returns false. Moving for
each km causes the petrolLevel to go low by one.
6. void Refill() – a function that refills the car tank to the maximum value of petrolLevel
7. bool isEmpty() – a function that tells whether the Petrol tank is Empty or not
write a program to find if a given number is positive or negative in python
The first line will contain a message prompt to input the value of n.
The second line contains the sum of all odd numbers from 0 to n.
Write a console application that uses at least five different method of math class. Provide a meaningful identifier of the variables are constant. Name the namespace as mathApp and it's class as mathProgram.
Write a recursive function that returns number of occurrences of a certain letter in a given string.
Let the function prototype be int countLetter(char letter, string str). For example, if
letter = "l" and str = "lollipop", the function should return 3.
Write console application that initializes at least five variables or constant with different data types then display their values. Provide a meaningful identifier of the variable or constant.