关于C语言if语句程序的问题?请高手来帮忙看下错哪里。

来源:百度知道 编辑:UC知道 时间:2024/06/19 23:24:08
#include <stdio.h>

void main()
{
int age = 0;
int savings = 0;

printf("\nEnter your age is:");
scanf("%d",&age);
printf("\nEnter your saving is:");
scanf("%d",&savings);

if(age > 12 && age < 20 && savings > 5000);
printf("\nYou are a rich teenager.");

if(age > 20 | savings < 5000);
printf("\nYou are not a teenager and rich.");
getch();

}

为什么不管输入什么都会得到俩个结果呢。我用的编译器是WINTC。请懂的人帮忙指点一下。谢谢各位了。
if(age > 20 | savings < 5000);
这个中的或条件应该是|| 是我提问是忘打了个|

就是改成if(age > 20 || savings < 5000);
还是和上面发生的情况一样。

知道错在哪里的请帮忙解答下。谢谢了。

if(age > 20 || savings < 5000);
我记得c中的或条件是'||'吧

if(age > 12 && age < 20 && savings > 5000);
你if后面这个';'也是打错了?还是程序也是这样?那肯定不对