CODE NO:- 20 Print the below pattern #LOGIC Take a variable and assign it with value 0(zero) then keep incrementing it by 1 in the inner loop. #Program( In C): In C language we use ' // ' for Single line comment and /*---*/ for multi line comment #include<stdio.h> // header file for i/p and o/p int main() { int i,j,a=0,n; printf("\n enter the no. of rows:"); scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<n;j++) { printf("%3d",++a);// %3d is used to display the pattern correctly } printf("\n"); } /* %3d is a format specifier where % means "print the variable here" 3 means "use at least 3 spaces to display, padding as needed" d means integer putting the above sentences together we can say that: "print...
Comments
Post a Comment