[My site ]
Main » 2013 » December » 12 » 2010-2011 question 1
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;
}

Category: C Programming - 1 | Views: 313 | Added by: ahansaary | Rating: 0.0/0
Total comments: 0
Only registered users can add comments.
[ Sign Up | Login ]