Write a program that inputs several(three) lines of text and a search string, and determines the total occurrences of the string in the lines of text.
Write a class and member functions for a class complex as follows
Class complex
{
Int re, img;
public:
complex (int =0,int=0);
complex(complex &);
void accept();
void display();
complex add(const complex &);
CODE
#include <iostream>
class Rectangle
{
public:
Rectangle() {}
explicit Rectangle(float i) : length(i), breadth(i)
{}
Rectangle(float a, float b) :length(a), breadth(b)
{}
void Calculate() { std::cout << length * breadth<<std::endl; }
private:
float length {0},
breadth {0};
};
int main()
{
Rectangle r1;
Rectangle r2{ 10 };
Rectangle r3{ 15,45 };
r1.Calculate();
r2.Calculate();
r3.Calculate();
return 0;
}
How do I write my name in beginning of this program ?
question is related to number string i passed two test cases as 1. I am 25 years and 10 months old---output(sum is 30, avg is 17.5) 2. tech foundation 35567 output(sum is 35567, avg is 35567.0)---got 2 text cases
but iam not getting 3. anjali25 is python4 expert output(sum=29, avg=14.5)
a=input().split()
sum=0
count=0
for i in a:
is_digit=i.isdigit()
if is_digit:
number=i
count+=1
sum=sum+int(number)
print(sum)
avg=sum/count
print(avg)
Write necessary class and member function definitions for a cricket player object. (Use array of objects).
The program should accept details from user (max 10) : player code, name, runs, Innings, played, number of times not out.
The program should contain following menu:-
Enter details of players.
Display average runs of a single player.
Average runs of all players
Write an overloaded function to concatenate two strings using + operator overloading.
Design a code for inheritance for that consider three classes namely grandfather, father and child. Each one of them has a character data type member. Each class contain a pair of constructor and destructors. The father is derived from the class grandfather. Similarly the class child is derived from class father. The class grandfather is a base class of the class father. The class father is a base class of the class child. The class child is derived from the class father. The class father is intermediate classes that act as a base class as well as derived class. Constructors are executed from the base class to the derived class and destructors are executed from the derived class to the base class.
Triplet Sum
Given an array n integers, find and print all the unique triplets (a, b, c) in the array which give the sum K. (a+b+c=K).Input
The first line of the input will be space separated integers, denoting the elements of the array. The second line of the input will be an integer denoting the required sum KOutput
The output should be multiple lines, each line containing a unique triplet. The elements of the triple must be sorted in increasing order and all the triplets printed must be sorted in increasing order. Print "No Matching Triplets Found" if there are no triplets with the given sum.Explanation
When the given array is [0, 1, 2, 3, 5, 7, 13, 17, 19, 19] and the required sum is 22, the triplets (0, 3, 19), (0, 5, 17), (1, 2, 19), (2, 3, 17) and (2, 7, 13) have the given sum 22.
Sample Input 1
0 12 17 8 9 21
29
Sample Output 1
(0, 8, 21)
(0, 12, 17)
(8, 9, 12)
Sample Input 2
0 1 2 3 5 7 13 17 19 19
22
Sample Output 2
(0, 3, 19)
(0, 5, 17)
(1, 2, 19)
(2, 3, 17)
(2, 7, 13)
Non-Adjacent Combinations of Two Words
Given a sentence as input, find all the unique combinations of two words and print the word combinations that are not adjacent in the original sentence in lexicographical order.Input
The input will be a single line containing a sentence
The output should be multiple lines, each line containing a valid unique combination of two words. The words in each line should be lexicographical order and the lines as well should be in lexicographical order. A valid combination will not contain the words that appear adjacent in the given sentence. Print "No Combinations" if there are no valid combinations
programming python
Sample Input 1
raju always plays cricket
Sample Output 1
always cricket
cricket raju
plays raju
Sample Input 2
python is a programming language
Sample Output 2
a language
a python
is language
is programming
language python
programming python
Sample Input 3
to be or not to be
Sample Output 3
be be
be not
or to
to to
Define a class string. Use different constructors and do the following [20 marks]
- Create un-initialized string objects
- Create objects with string constants
- Concatenate two strings
- Display desired strings