Program in C and C++ to print arrow pattern
*
*
*
* * * *
*
*
*
C Program
#include<stdio.h> int main(){ int i, j; for(i = 1; i <= 7; i++){ for(j = 1; j <= 4; j++){ if(i <= 3){ if(i == 5 - j) printf(" *"); else printf(" "); } else if(i == 4) printf(" * "); else{ if(i == 3 + j) printf(" *"); else printf(" "); } } printf("\n"); } return 0; }
C++ Program
#include<iostream> int main(){ int i, j; for(i = 1; i <= 7; i++){ for(j = 1; j <= 4; j++){ if(i <= 3){ if(i == 5 - j) std::cout<<" *"; else std::cout<<" "; } else if(i == 4) std::cout<<" * "; else{ if(i == 3 + j) std::cout<<" *"; else std::cout<<" "; } } std::cout<<"\n"; } return 0; }
Output :-
Output
Related Programs
0 Comments