300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > c语言编程if语句的用法 if句子用法(C语言中 if语句的用法)

c语言编程if语句的用法 if句子用法(C语言中 if语句的用法)

时间:2019-11-05 11:42:37

相关推荐

c语言编程if语句的用法 if句子用法(C语言中 if语句的用法)

if语句的用法

if语句的用法其实和我们日常说话是一样的:

如果……那么……

譬如,如果变量A大于10,那么标签1显示真

if(变量A>10)

标签1.标题=“真”

If在句子中的用法都有哪些

if在句中和句首的用法一样,只是if放在句首,有如果的意思;if放在句中,有如果 、是否的意思。

【附】if和whether的区别

一、引导宾语从句,一般既可用whether也可用if。但or not放在whether之后时,只能用whether不用if。

【例句】:I don’t know whether or not he will come.

我不知7a686964616fe4b893e5b19e31333365653331道他是不是回来。

注1:如果or not放在whether所引导的从句句尾,则可以用if来替换。

【例句】:I don’t know whether/if he will come or not.

我不知道他是不是回来。

注2. 在强调任意选择时,用whether…or,此时不用if替换whether。

【例句】:He asked me whether I wanted to go there by train or by bus.

他问我是想乘火车还是坐公共汽车去那里。

注3:whether和or一起还有“不管”之意,引导让步状语从句。

【例句】:Whether he drives or takes the train, he will be here on time.

不管开车来还是乘火车来,他都会准时到。

二、在引导主语从句、表语从句、同位语从句时一般用whether不用if。

如:

⑴ Whether it is true remains a question.(主语从句)

那是不是真的还是个问题。

⑵ The question is whether it is true.(表语从句)

问题是是不是真的。

⑶ We have a doubt whether it is true.(同位语从句)

我们怀疑那是不是真的。

注:whether引导主语从句放在主句之后时可用if来代替。

【例句】:It is unclear whether/if he likes the present.

他是不是喜欢那个礼物还不清楚。

三、用在动词不定式之前时用whether不用if。

【例句】:I don’t know whether to go there at once.

我不知道是不是该立刻去那里。

if语句用法

if(表达式)语句1

else 语句2

无论真假它都只执行一次

如果表达式的值是真的,直接去执行语句1,然后它是直接跳过else,去执行下个语句

如果表达式结果为假,执行else后的语句

C语言中,if语句的用法

if是真的话那么程序则执行if里的语句。。。

既然if是真,那么else当然不会运行。。

if else的意思是 如果if是真那么只运行if,如果(((if是假就运行else..)))

多练习下很容易掌握的,,,,每个else只能对他前面的一个if起作用也就是看else只看他前面的一个if

列:

main()

{

float grade;

int n1=0,n2=-1;

system("cls");

while(grade!=-1)

{

printf("grade[]:=");

scanf("%f",&grade);

if(grade>=60) (((((((如果grade大于等于60

n1++; (((((((((((((((那么n1+1;

else ((((((((((((((((else看他上一个if

n2++; (((((((((((((((即如果上一个if里是假。。。 那么n2+1

}

printf("YES---%d\tNO---%d",n1,n2);

getch();

}

If的用法

If不是只表示虚拟语气,它有三种用法:

1 (表示条件)如果 ,主句用将来时,if从句用现在时表示将来

He will come if you invite him. 如果你请他,他会来的。

2. (表示虚拟)假如,要是

1)时态:可以表示过去,现在和将来的情况。它的基本特点是时态退后。

a. 同现在事实相反的假设。

句型 : 条件从句 主句

一般过去时 should( would) +动词原形

If they were here, they would help you.

b. 表示于过去事实相反的假设。

句型: 条件从句 主句

过去完成时 should(would) have+ 过去分词

If she had worked harder, she would have succeeded.

The rice would not have been burnt if you had been more careful.

If my lawyer had been here last Saturday, he would have prevented me from going.

c. 表示对将来的假想

句型: 条件从句 主句

一般过去时 should+ 动词原形

were+ 不定式 would + 动词原形

should+ 动词原形 would + 动词原形

If you succeeded, everything would be all right.

If you should succeed, everything would be all right.

If you were to succeed, everything would be all right.

3. 是否 = whether 连接宾语从句

I wonder if she is ill. 不知她是否病了。

-----------------------------------

如有疑问欢迎追问!

满意请点击右上方【选为满意回答】按钮

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。