I'm having kinda of trouble. The code I wrote down below it's letter A, and i don't know how to cut on right side to get it to look like letter P. I know this is simple to some of you, but please I really need this help.
#include<stdio.h>
main(){
int rows,position,i,j;
do{
printf("insert rows, it must be odd number:");
scanf("%d",&rows);
}while(rows%2==0);
printf("Insert number of positions, it must be at least half of rows");
scanf("%d",&positions);
for(i=1;i<=rows;i++){
for(j=1;j<=position;j++){
if(i==1 || i==(rows/2)+1 || j==1 || j==positions){
printf("/ ");
}
else{
printf(" ");
}
}
printf("\n");
}
example:
rows:13
positions:7
now goes print:
///////
/ /
/ /
/ /
/ /
/ /
///////
/ /
/ /
/ /
/ /
/ /
/ /
What I need is this
///////
/ /
/ /
/ /
/ /
/ /
///////
/
/
/
/
/
/
In your if
statement, change:
j==positions
to:
(j==positions && i <= (rows/2)+1)
That will block that column after i
passes (rows/2)+1
.