其他分享
首页 > 其他分享> > C语言 8.0

C语言 8.0

作者:互联网

初学C语言,如有偏颇,还望海涵;
int main()
{
int iNumber= 1;
int iSum=0;
while(iNumber<=100)
{
iSum=iNumber+iSum;
iNumber++;
}
printf("the sum is : %d\n",iSum);
return 0;
}
求和1加到100;
在这里不做介绍了;

int main()
{
int iNumber=1;

    while(iNumber!=0)
    {
         printf("---------Menu-------------\n");
             printf("---------Sell---------------1\n");
             printf("---------Buy---------------2\n");
             printf("---------Showproduct---3\n");
             printf("---------Out----------------0\n");

             scanf("%d",&iNumber);// 打印函数,接收输入数据;
             switch(iNumber)
             {
              case 1:
                   printf(”you are buying soming into store\n");
                     break;
                case 2:
                   printf("you are selling soming into store\n");
                     break;
                case 3:
                   printf("checking the store\n");
                     break;
                case 0:
                     printf("the program is out\n");
                     break;
                default:
                   printf("you put a wrong selection\n");
                   break;
             }
    }   
           return 0;

}
顾客用户菜单,每一次点击进行一次循环,直到输入0,结束循环;一个简单的循环语句,不做过多介绍;

标签:8.0,int,iNumber,iSum,C语言,break,printf,---------
来源: https://blog.51cto.com/15098536/2623595