nylonelyguy
Technical User
hello all! i am hoping to get some help here. i am new to programming. i was asked to do these 2 programs. im sure they are nothing to u. so please who ever can help reply to my post.
1. write a program that read five numbers between 1 and 30 for each number read, your program should print al ine containing that number of adjacent asterisks. example.
2 4 5 6 8
**
****
*****
******
********
i tried here but that didnt work.
#include <iostream.h>
void main()
{
int i;
cout<< "Enter 5 numbers between 1 and 30 ";
cin >>i;
//--- Loop counting i up from 1 to n.
// Initialize counter.
for ( i=1; i<=30
{
// Test counter.
cout << "*";
i++; // Increment counter.
}
cout << endl;
}
2. second program is to write a program to compute the exponent of x^n. im not allowed to use pow() function.
where{x>0 ; n>=0}.
example
s^3=8
i tried this , but i dont think it is right.
#include <iostream.h>
void main(void)
{
int num = 0;
cout << "Number Number Squared Number Cube\n";
cout << "-------------------------------------------\n";
while (num++ < 10)
cout << num << "\t\t\t\t" << (num * num)<<"\t\t\t\t"<<(num*num*num) << endl;
}
Thank you so much
1. write a program that read five numbers between 1 and 30 for each number read, your program should print al ine containing that number of adjacent asterisks. example.
2 4 5 6 8
**
****
*****
******
********
i tried here but that didnt work.
#include <iostream.h>
void main()
{
int i;
cout<< "Enter 5 numbers between 1 and 30 ";
cin >>i;
//--- Loop counting i up from 1 to n.
// Initialize counter.
for ( i=1; i<=30
{
// Test counter.
cout << "*";
i++; // Increment counter.
}
cout << endl;
}
2. second program is to write a program to compute the exponent of x^n. im not allowed to use pow() function.
where{x>0 ; n>=0}.
example
s^3=8
i tried this , but i dont think it is right.
#include <iostream.h>
void main(void)
{
int num = 0;
cout << "Number Number Squared Number Cube\n";
cout << "-------------------------------------------\n";
while (num++ < 10)
cout << num << "\t\t\t\t" << (num * num)<<"\t\t\t\t"<<(num*num*num) << endl;
}
Thank you so much