+ 1

a program to print the following output:- 1234* 123*5 12*45 1*345 *2345

using for loop if possible

14th Aug 2016, 10:58 PM
Asim
Asim - avatar
3 Answers
+ 1
#include <iostream> using namespace std; int main() { cout << "1234*" << endl << "123*5" << endl << "12*45" << endl << "1*345" << endl << "*2345"; return 0; } easiest way
15th Aug 2016, 9:41 PM
lazyguy
- 1
You may have to create an array that has 12345. Then declare * as a char. That's when I would think you could use the for loop to make each number in the array be replaced by *. Ex: for(i=5;i<=0;i--){ arr[i]=char //char being the * cout<<arr[] <<endl; //would state the array } Hope that helps!
14th Aug 2016, 11:33 PM
Hannah Bernal
Hannah Bernal - avatar