Q1
recursive function that receives an integer x and prints the alternating alphabetic characters Write a main function to test the function;
ENTER NUMBER : 4
A C E G
Q#2
Define a void function that finds the smallest value in the array and number of its occurrences. Also, it finds the largest value in the array and number of its occurrences.
ENTER 4 NUMBERS:
1 12 5 41 41
THE BIGGEST IS 41 AND IT OCCURS 2 TIME
THE SMALLEST IS 1 AND IT OCCURS 1 TIME
There are many ways to do that.
For example a while loop like this in your main function:
1 2 3 4 5 6 7 8 9
string some_string;
while(true) {
cin >> some_string;
if (some_string == "exit") return;
if (some_string == "power program")
//call the PowerProgram function
else
//call the SumProgram function
}
Thank you to help me
and I have another question
please help me
question#1:
Write a C++ program that reads integers until 0 is entered .For each entered number, the program checks whether it is an odd or an even number and print an appropriate message . Use IsEven() function that receives an integer and return true if it's even , otherwise it returns false.
The sumple run is:
Enter set of numbers and 0 to stop .
12
12 is an even number.
11
11 is an odd number.
3
3 is an odd number.
0
Press any key to continue ...
question #2:
Write a C++ function that displays a triangle pattern as shown below, based on the received size. . Write an appropriate main program to examine this function.
The sample run is:
Enter the size :10
**********
*********
********
*******
******
*****
****
***
**
*
Press any key to continue ...
The teacher want a brief answer
if you can
and thank you for help me again *_*
HELP ME PLEASE
I wrote code but, I dont know where is the error at yet.
I want run
lesson about function and call the funcion.
Question:
Write a c++ program that keeps displaying the following menu driven:
• Power Program ( xn ) : define a function that returns x powered to n .
• Sum Program ( sum = 1+ 2+ 3+ 4+ … + n ) ) : define a function that returns the sum of the integers between 1 and n.
• Exit : display Bye message.
The program should stop when the user selects the exit option.
- sumple run:
Please select one of the following :
1-Power Program.
2-Sum Program.
3-Exit
your choice? 1
Enter an Integer?3
Enter the Wanted Power?2
3 Power 2 = 9
Please select one of the following :
1-Power Program.
2-Sum Program.
3-Exit
your choice? 2
Enter an Integer?4
Sum=10
Please select one of the following :
1-Power Program.
2-Sum Program.
3-Exit
your choice? 3
Bye
Press any key to continue ...
my cdoe Is:
#include<iostream>
#include<string>
using namespace std;
int PowerProgram(int x , int n)
{
int y , z;
return x*n;
}
string SumProgram(int s)
{
int sum;
sum=sum++;
}
int main()
{
int cho;
cout<<"Plese select one of the following :"<<endl;
cout<<"1-Power program.\n2-Sum program.\n3-Exit"<<endl;
cin>>cho;
string some_string;
while(true) {
cin >> some_string;
if (some_string == "exit") return;
if (some_string == "power program")
{
PowerProgram;
}
else
SumProgram;
}
return 0;
}
and this question also:
Write a C++ program that reads integers until 0 is entered .For each entered number, the program checks whether it is an odd or an even number and print an appropriate message . Use IsEven() function that receives an integer and return true if it's even , otherwise it returns false.
sumple run:
Enter set of numbers and 0 to stop .
12
12 is an even number.
11
11 is an odd number.
3
3 is an odd number.
0
Press any key to continue ...
I... Think it would be best if you looked at the tutorials on this site. I'm also not certain as to why sumprog() is a string? Nor does it print a value...
q1 -- weite function that receives an integer and prints the equivalent representation in binary system. The received integer must be a positive number
use call by value or by refrence
you can use global or local values
You better spend a few hours learning the basics of software development, just google "C++ Tutorial" or something like that, then you'll be able to solve these problems in no time ;)
write function that receives int and prints the equivalent representation in binary system. The received int must be a positive number smaller than 100;
my code with error
help me please;
and how can i write this function?
receives the kilowatt-hours used and returns the charge for electricity for a customer. Electric charges are 0.95 S.R per kilowatt.