02writingyourfirstprogram写你的第一个c程序(代码片段)

忘记背后,努力面前;活出见证,荣耀基督!犹太人认为他们是上帝 忘记背后,努力面前;活出见证,荣耀基督!犹太人认为他们是上帝的子民,所以他们比其他人更努力、更勤奋,     2022-12-26     804

关键词:

Let‘s print "Hi" 打印输出“Hi”

技术图片

In your first computer program, let‘s print something on the screen to display.
在您的第一个计算机程序中,让我们在屏幕上打印一些内容进行显示。
How can we instruct a computer to print "Hi" on the screen in simple English?
我们怎样才能指导计算机用简单的英语在屏幕上打印“Hi”呢?


技术图片

Did something similar come to your mind?
你有没有想到过类似的事情?

print Hi

Great!棒!
Now, let‘s think from a computer‘s perspective and do afew changes to our command.
现在,让我们从计算机的角度考虑,对我们的命令做一些更改。


Adding changes to your command.向你的命令中添加更改。

Round Brackets 圆括号

技术图片
Round Brackets: Round brackets will help the computer to separate the print command from the text which we want to print.
Now our command will change to:
圆括号:圆括号将帮助计算机将打印命令与我们要打印的文本分开。
现在我们的命令将更改为:

print (Hi)

Double Quotes 双引号

技术图片

Double Quotes: In C language, the text to be printed is always enclosed within double quotes. We call this text a string.
So our command will change to:
双引号:在C语言中,要打印的文本总是用双引号括起来。我们称此文本为字符串
因此,我们的命令将更改为:

print (" Hi ")

Semicolon 分号

技术图片

Semicolon: In C, we use semicolon at the end of each command to indicate the computer thatit‘s the end of a command
Now our command will change to:
分号:在C语言中,我们在每个命令的末尾使用分号来表示计算机是命令的末尾。
现在我们的命令将更改为:

print ("Hi");

printf

Wait a minute, there is one more thing.
In ‘C‘ language, we use printf instead of just the print command
So our final code i.e. the command to print the text "Hi‘ on the computer screen will be:
等一下,还有一件事。
在C语言中,我们使用printf而不仅仅是print命令。
因此,我们的最终代码(即在计算机屏幕上打印文本“Hi”的命令)将是:

printf ("Hi");

The result of the above command will be:
上述命令的结果将是:
Output 输出:

Hi


Let‘s have some fun! Change the command below to print your name instead of the text.
让我们来娱乐一下!更改下面的命令以打印您的姓名

printf (" Hello ____ ");

Fill in the blanks
填空

printf (" Hello MosesMin ");

Output

Hello MosesMin

技术图片

Congratulations!
Now, you know how to print any text in the C language!
Maybe now you can create a personal robot for yourself!
Just kidding:P

现在,您知道如何用C语言打印任何文本了!
也许现在你可以为自己创造一个个人机器人了!
开个玩笑:P

Let‘s print on new line 打印一个新行

Use of " " 使用“ ”

Let‘s learn one more thing.
Suppose you want to print your first name in one line and your last name in the next line, you will have to use at the end of your first name.
tells the computer to go to the next line before printing the next text.
is referred to as the newline character.
让我们再学一件事。
假设您想要在一行打印您的名字,在下一行打印您的姓氏,那么您必须在名字的末尾使用"
"告诉计算机在打印下一行文本之前转到下一行。
称为换行符

So you can now use below commands to print your first name and last name
因此,您现在可以使用以下命令打印您的名字和姓氏

printf ("Moses
");
printf ("Min");

Output

Moses
Min

If we miss , and write as follows:
如果我们漏写了 ,写成下面这样:

printf ("Moses");
printf ("Min");

The Result will be
结果将会是
Output输出:

MosesMin

Please note 请记住,C是区分大小写的语言

技术图片

Please note that ‘C‘is a case sensitive language. If you write Printf instead of printf, you will get an error. However, C does not care about extra spacing.
Because the meaning of Printf and printf is different for the computer.
请注意,‘C’是区分大小写的语言,如果您写Printf而不是printf,会得到一个错误。但是,C并不关心额外的空格。
因为Printf和printf对于计算机的含义是不同的。

Complete the program 完善下面的程序:

printf("I like programming" _;
printf("I like programming");

Now you know how to tell the computer to print some text onthe screen, in ‘C‘ language.
But our program is still incomplete.
To be able to make any program actually work and produce desired results i.e. to ‘Run‘ a program, we will have to add few more commands.
Let‘s see how to do it.
现在你知道如何告诉计算机用“C”语言在屏幕上打印一些文本了。
但是我们的程序还不完整。
为了能够使任何程序实际工作并产生所需的结果,即“运行”程序,我们将不得不添加更多的命令。
让我们看看怎么做。

Complete program 完善程序

Step 1: Add below commands to your program 步骤1:将以下命令添加到您的程序中

main函数 主函数

int main()
  return 0;

Don‘t be scared by looking at the above commands, let‘s make it easy for you by dividing it into different parts.看上面的命令不要害怕,让我们把它分成不同的部分,这样就容易了。

  • int main(): Every C program requires a main function to be executed.

  • int main():每个C程序都需要执行一个main函数。

    • A function is nothing but a group of commands. Hence,all the commands that you will be learning during our course will be written inside this function.
    • 函数只是一组命令。因此,您在本课程中将学习的所有命令都将写入此函数中。
  • The int represents the output of the function. The main function always returns an integer, hence it starts with an"int"

  • int表示函数的输出。main函数总是返回整数,因此它以“int”开头。

  • : Commands will be written inside the open and closed curly brackets ....

  • :命令要写在左花括号和右花括号内...。

  • And at the end of your commands, you need to return some value,so, we used ‘return O;‘ This tells the computer that you have ended your main function and you want to return 0 as the integer value.

  • 在命令的末尾,您需要返回一些值,因此,我们使用‘return 0’;这告诉计算机您已经结束了main函数,并且您希望返回0作为整数值。

Now you will be able to run the program, click on Run
现在您就可以运行该程序了,单击Run。

int main()
  return 0;

After running the above program, the output will be
运行上述程序后,输出将是
Output
输出结果:

What happened? You are not able to see anything in Result box right?
发生了什么?您在结果框中看不到任何内容,对吗?

#include<stdio.h>

That is because we haven‘t written our printf command. You simply told the computer to compute this function but you did not tell it to display the result Let‘s do it.
But before that you will have to add #include <stdio.h> command at the very beginning of our program.
We will see the actual meaning of this command later in our course.

这是因为我们还没有编写printf命令。你只是告诉计算机计算这个函数,但是你没有告诉它显示结果,让我们去做。
但在此之前,您必须在程序的最开始添加#include <stdio.h>命令。
我们稍后将在课程中看到此命令的实际意义。

fun test 娱乐测试学习环节

Let‘s finally complete our entire program which we can run and produce the expected output i.e.
result.Write your name in the blank
让我们最终完成我们的整个程序,我们可以运行该程序并产生预期的输出,即。
结果。在空白处写上你的名字

#include <stdio.h>
int main()
  printf (" Hi _______");
  return 0;

Fill in the blanks 填空

#include <stdio.h>
int main()
  printf (" Hi MosesMin");
  return 0;

Output 输出

Hi MosesMin

技术图片

Hurrah! you just ran your very first program in ‘C‘ language.
Think about why the 0 did not display in your output (pause and think).
It is because you did not tell the computer to display it!
万岁!你刚刚用“C”语言运行了你的第一个程序。
想一想为什么0没有显示在您的输出中(暂停并思考)。
那是因为你没有告诉电脑显示它!

Arrange the below commands in correct order to produce the following output:
按正确顺序排列以下命令以生成以下输出:

Hello World
I like C programming

Arrange the following in correct sequence 按正确的顺序安排以下内容

1 #include <stdio.h>
2 int main()
3   printf("Hello World");
4   printf("I like C programming");
5   return 0;
6 

技术图片







































































数据表滚动连接中缺少键(代码片段)

...有两个数据表-xtab和ytab。>xtabidcreated_atupdated_at1:954732019-02-0103:36:342019-02-0103:52:442:954732019-02-0723:35:462019-02-0723:59:133:954732019-02-0900:05:432019-02-0900:24:594:954732019-02-1302:21:152019-02-1302:49:245:954732019-02-1323:48:552019-02-1400:17:326:42682019-02-1515:59:... 查看详情

将 Snowflake 中的 2021-08-02T02:11:07.299+0000 转换为 2021-08-02 02:11:07.299 所需的函数

】将Snowflake中的2021-08-02T02:11:07.299+0000转换为2021-08-0202:11:07.299所需的函数【英文标题】:Functionneededtoconvert2021-08-02T02:11:07.299+0000to2021-08-0202:11:07.299inSnowflake【发布时间】:2021-09-1502:59:58【问题描述】:我正在通过JSON提取时区,其... 查看详情

源码-0205-02--聊天布局02

 //XMGChatingViewController.m//07-聊天布局#import"XMGChatingViewController.h"#import"XMGMessage.h"#import"XMGMessageCell.h"@interfaceXMGChatingViewController()<UITableViewDataSource,UITableViewDel 查看详情

从“JAN02/19 到 2019-01-02”的日期转换

】从“JAN02/19到2019-01-02”的日期转换【英文标题】:Dateconversionfrom"JAN02/19to2019-01-02【发布时间】:2020-01-1516:32:05【问题描述】:如何将varchar(25)列的值从“JAN02/19”格式的日期转换为“2019-01-02”(YYYY-MM-DD)?【问题讨论】:每... 查看详情

02windowsserver2003域账户管理(02)

02.用dsadd在名为test的ou中添加一个账户alice,电话号码1233234br/>用dsmod修改alice的电话为110,邮件地址为[email protected]用dsrm删除alice账户 查看详情

正方体 3.02.02 崩溃 JRE

】正方体3.02.02崩溃JRE【英文标题】:Tesseract3.02.02CrashJRE【发布时间】:2017-03-2812:35:44【问题描述】:我们正在使用Tess4J/Tesseract在web应用程序上执行OCR。在Windows上一切正常,但在Linux机器(CentOS6.8)上部署时,程序崩溃并自动终... 查看详情

源码-0205-02--表格数据的更新02

  //XMGDealsViewController.m//06-自定义等高cell01-storyboard#import"XMGDealsViewController.h"#import"XMGDeal.h"#import"XMGDealCell.h"@interfaceXMGDealsViewController()<UITableViewDataSource,UI 查看详情

Python MySQLdb 日期时间值不正确:'2018-03-25 02:00:02'

】PythonMySQLdb日期时间值不正确:\\\'2018-03-2502:00:02\\\'【英文标题】:PythonMySQLdbIncorrectdatetimevalue:\'2018-03-2502:00:02\'PythonMySQLdb日期时间值不正确:\'2018-03-2502:00:02\'【发布时间】:2018-09-1115:07:02【问题描述】:我在Python上使用mysqlclie... 查看详情

201704f-02创建财务凭证

一、F-02创建财务凭证-BDC期初余额导入程序程序:ZFIU_LDV_F_02_UPLOAD创建F-02凭证:*&----------------------------------------------------------------------------------------------------CALLTRANSACTION‘F-02‘USINGit_bdcdataMO 查看详情

极客时间每日一课

19-02-22_19-02-22_19-02-22_19-02-22_19-02-22_19-02-22_19-02-22_19-02-22_ 查看详情

心脏病数据挖掘数据

70.01.04.0130.0322.00.02.0109.00.02.42.03.03.0267.00.03.0115.0564.00.02.0160.00.01.62.00.07.0157.01.02.0124.0261.00.00.0141.00.00.31.00.07.0264.01.04.0128.0263.00.00.0105.01.00.22.01.07.0174.00.02.0120.0269.00.02.0121.01.00.21.01.03.0165.01.04.0120.0177.00.00.0140.00.00.41.00.07.0156.01.03.0130.0256... 查看详情

2018.02.02-现货黄金

现货黄金操作总结1.跟单操作,白天跟着指导老师走,一般不会有亏损,可以适当的加大手数,目前最多可以为0.2手2.对于挂单,目前来看具有不确定性,现在先挂0.1单即可这周才开始跟着喊单操作,有些东西还没有见到过,一... 查看详情

基于日期顺序的排名

...3-11-1904:58:10【问题描述】:我的数据如下**HeadingDate**A2009-02-01B2009-02-03c2009-02-05d2009-02-06e2009-02-08我需要排名如下HeadingDateRankA2009-02-011B2009-02-032c2009-02-051d2009-02-06 查看详情

是否可以从 2011-02-27 02:04:46 这样的日期获取 UNIX 时间? [复制]

】是否可以从2011-02-2702:04:46这样的日期获取UNIX时间?[复制]【英文标题】:IsitpossibletogetUNIXtimefromsuchdate2011-02-2702:04:46?[duplicate]【发布时间】:2011-08-1014:18:55【问题描述】:Mktime和其他函数对2011-02-2702:04:46这样的日期给出错误的... 查看详情

sql2013-02-02任务-将权重和批量计算加倍后端(代码片段)

查看详情

每日总结2020/02/02

  早上读完了《构建之法》的第四章,随后开始了一天的安排。  主要的学习任务还是以认识为主,我注册了自己的GitHub账号,由于使用了谷歌浏览器,自带翻译功能,所以能看懂,也尝试看了一点jQuery,ajax的文章,理解... 查看详情

02css选择符

查看详情

ios怎么使用md5进行加密

...en(cStr),result);//Thisisthemd5callreturn[NSStringstringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",result[0],result[1],result[2],result[3],result[4] 查看详情