Answer:
see explaination
Explanation:
#include <iostream>
#include <string>
using namespace std;
class Employee
{
string name;
int salary;
public: Employee()
{
}
Employee(string name, int salary)
{
this->name=name;
this->salary=salary;
}
void setName(string name)
{
this->name=name;
}
void setSalary(int sal)
{
this->salary=sal;
}
string getName()
{
return name;
}
int getSalary()
{
return salary;
}
void raiseSalary(int percentage)
{
if(percentage<0)
{
cout<<"Invalid percentage";
}
else
{
salary=salary+((float)percentage/100)*salary;
}
}
};
int main()
{
int percentage;
Employee e1("Satur",1000);
cout<<"Employee details are:";
cout<<e1.getName();
cout<<e1.getSalary();
cout<<"Enter the percentage raise";
cin>>percentage;
e1.raiseSalary(percentage);
cout<<"Raise in salary:";
cout<<e1.getSalary();
return 0;
}
Answer:
The algorithm is as follows:
1. Input sentence
2. Input character
3. Length = len(sentence)
4. count = 0
5. For i = 0 to Length-1
5.1 If sentence[i] == character
5.1.1 count++
6. Print count
7. Stop
The program in C++ is as follows:
#include <iostream>
#include <string.h>
using namespace std;
int main(){
char str[100]; char chr;
cin.getline(str, 100);
cin>>chr;
int count = 0;
for (int i=0;i<strlen(str);i++){
if (str[i] == chr){
count++;} }
cout << count;
return 0;}
Explanation:
I will provide explanation for the c++ program. The explanation can also be extended to the algorithm
This declares the string and the character
char str[100]; char chr;
This gets input for the string variable
cin.getline(str, 100);
This gets input for the character variable
cin>>chr;
This initializes count to 0
int count = 0;
This iterates through the characters of the string
for (int i=0;i<strlen(str);i++){
If the current character equals the search character, count is incremented by 1
if (str[i] == chr){ count++;} }
This prints the count
cout << count;
Answer:
d
Explanation:
because all in one question form
Generally invisible to the user, like you can't see it on your OS or in just a standard application
Graphics are important in multimedia application this is because humans are visually oriented etc.