0

can someone tell me a programme to output this kind of pattern : ?***? ?*? ?

7th Sep 2016, 1:20 PM
Sarthak Behki
Sarthak Behki - avatar
3 Answers
+ 3
#include<iostream> using namespace std; int main() { for(int loop=1;loop<=3;loop++) { for(int i=1;i<=loop-1;i++) cout<<" "; for(int p=loop;p<=6-loop;p++) { if(p==loop||p==6-loop)cout<<"?"; else cout<<"*"; } cout<<"\n"; } return 0; }
7th Sep 2016, 1:48 PM
Shaurya Agnihotri
+ 3
Edited. int i, j, n; n = 2; for (i = 0; i <= n; i++) { for (j = 0; j < i; j++) { cout << " "; } cout << "?"; for (j = 0; j < (n-i)*2-1; j++) { cout << "*"; } if (i != n) { cout << "?"; } for (j = 0; j < i; j++) { cout << " "; } cout << endl; }
7th Sep 2016, 2:10 PM
Zen
Zen - avatar
0
thanks! I'll try it out in a bit :)
7th Sep 2016, 1:48 PM
Sarthak Behki
Sarthak Behki - avatar