11:58 PM 2010-2011 question 1 |
write a program print that pattern by while statement
+*+*+*+
*+*+*+*
+*+*+*+
*+*+*+*
#include"stdio.h"
main()
{
int i=1, j, nr, nc;
printf("enter num of raws : ");
scanf("%d", &nr);
printf("enter num of columns : ");
scanf("%d", &nc);
while(i<=nr){
j=1;
while(j<=nc){
if(i%2==1 && j%2==1 || i%2==0 && j%2==0){
printf("+");
}else{
printf("*");
}
j++;
}
printf("\n");
i++;
}
getch();
return 0;
}
|
|
Total comments: 0 | |