请帮我知道我的程序中的错误是什么! [英] please help me know what the error in my programme is!

查看:73
本文介绍了请帮我知道我的程序中的错误是什么!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<stdio.h>
#include<conio.h>
int main()
    {
    clrscr();
    int i=3,j=2,num,rem;
    printf("enter the number less than which you need all the prime numbers:");
    scanf("d",&num);
    while(i<=num)
        {
        j=2;
        while(j<=i-1)
            {
            rem=(i%j);
            if(rem==0)
                {
                break;
                }
            j++;
            }
        if(j==i)
            printf("%d\n",i);
        i++;
        }
    getch();
    return 0;
    }





缩进添加 - OriginalGriff [/ edit]



[edit]Indentation added - OriginalGriff[/edit]

推荐答案

你需要先看看基础知识。

You need to start with looking at the basics.
int i=3,j=2,num,rem;
printf("enter the number less than which you need all the prime numbers:");
scanf("d",&num);



如果你看一下scanf的定义: http://www.cplusplus.com/ reference / cstdio / scanf / [ ^ 你会看到d不是一个vlaid格式说明符:它应该是%d:


If you look at the definition of scanf: http://www.cplusplus.com/reference/cstdio/scanf/[^] you will see that "d" is not a vlaid format specifier: it should be "%d":

int i=3,j=2,num,rem;
printf("enter the number less than which you need all the prime numbers:");
scanf("%d",&num);



现在你将进入循环。


Now you will get into the loop.


这篇关于请帮我知道我的程序中的错误是什么!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆