问题描述
无法弄清楚如何制定正确的语法..我可以在循环语句中完成它但我的教授说只使用简单的if-else语句。问题是这样的。编写一个程序,确定你输入的数字是奇数还是偶数..
我试着编写这段代码..
#include< stdio.h>
main()
{
int nos;
clrscr();
printf(" Enter number:");
scanf("%d",& nos);
if(nos ++){
printf(" Odd number");
}
else {
printf(偶数);
}
getch();
}
Just cant figure out how to formulate the correct syntax..I can do it in looping statement but my professor said that use only the simple if-else statement. The problem goes like this..Write a program that will determine if the number that you entered is either odd or even number..
I tried writing this code..
#include<stdio.h>
main()
{
int nos;
clrscr();
printf("Enter number:");
scanf("%d",&nos);
if(nos++){
printf("Odd number");
}
else {
printf("Even number");
}
getch();
}
推荐答案
这篇关于if-else语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!