ข้อ 8 :
#include<stdio.h>
#include<conio.h>
main()
{
int i,w,sum;
sum=0;
for(i=1;i<=5;i++)
{
printf("Enter weight %d:",i);
scanf("%d",&w);
sum=sum+w;
}
printf("Summary of Weight = %d kg",sum);
getch();
}
ข้อ 9 :
#include<stdio.h>
#include<conio.h>
main()
{
int i,w,sum;
sum=0;
printf("Enter num:");
scanf("%d",&w);
for(i=1;i<=w;i++)
{
sum=sum+i;
}
printf("Summary = %d ",sum);
getch();
}
ข้อ 10 :
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,r,c;
printf("row:");
scanf("%d",&r);
printf("col:");
scanf("%d",&c);
for(i=1;i<=c;i++)
{
for(j=1;j<=r;j++)
{
printf("A");
}
printf("\n");
}
getch();
}
ข้อ 11 :
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n,c;
printf("char:");
scanf("%c",&c);
printf("number:");
scanf("%d",&n);
if(n>=4&&n<=9)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
printf("%c",c);
}
printf("\n");
}
}
getch();
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น