#include<stdio.h>
int main()
{
inti;
for(i=1i<=8i++)
printf("1234567890\n");
return0;
}
扩展资料:
for 循环语句的一般形式为:
for (表达式1; 表达式2; 表达式3)
{
语句;
}
首先要强调两点:
1) 表达式1、表达式2和表达式3之间是用分号;隔开的,千万不要写成逗号。
2) for(表达式1;表达式2;表达式3)的后面千万不要加分号,很多新手都会犯这种错误——会情不自禁地在后面加分号。
因为 for 循环只能控制到其后的一条语句,而在C语言中分号也是一个语句——空语句。所以如果在后面加个分号,那么 for 循环就只能控制到这个分号,下面大括号里面的语句就不属于 for 循环了。
根据题意可得代码:
#include <stdio.h>#include <stdlib.h>
int main()
{
int op
while (1){
printf ("---------Menu---------\n")
printf ("----Sell----------1\n")
printf ("----Buy-----------2\n")
printf ("----ShowProduct---3\n")
printf ("----Out-----------0\n")
scanf ("%d", &op)
switch(op){
case 1:
printf ("Selling the product\n")
break
case 2:
printf ("Buy the product\n")
break
case 3:
printf ("checking the store\n")
break
case 0:
printf ("the Program is out\n")
exit(0)
default:
printf ("Please reinput the operation\n")
}
}
return 0
}