اكتب برنامج بلغة C لعرض نمط لعدد n من الصفوف باستخدام رقم سيبدأ بالرقم 1 وسيكون الرقم الأول والأخير من كل صف هو 1
- برمجة
- برمجة سي c
- 2021-05-04
- Wassim
الأجوبة
/*Write a program in C to display the such a pattern for n number of rows using a number which will start with the number 1 and the first and a last number of each row will be 1*/
#include <stdio.h>
void main()
{
int i,j,n;
printf("Input number of rows : ");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
/* print blank spaces */
for(j=1;j<=n-i;j++)
printf(" ");
/* Display number in ascending order upto middle*/
for(j=1;j<=i;j++)
printf("%d",j);
/* Display number in reverse order after middle */
for(j=i-1;j>=1;j--)
printf("%d",j);
printf("\n");
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال