当前位置: 首页 > news >正文

C study notes[3]

文章目录

  • operatons
  • loops
  • references

operatons

  1. the fundamental operators such as +,-,* in C language can be simply manipulated.
int sum = 5 + 3;  // sum = 8
int difference = 10 - 4;  // difference = 6
int product = 6 * 7;  // product = 42

the operator / was left to introduce just a moment because that it’s special as follows.

5/2=2
5.0/2.0=2.5
5/2.0=2.5
int quotient = 15 / 4;  // quotient = 3 (integer division)
float result = 15.0 / 4;  // result = 3.75

the operator % can get the remainder after division

int remainder = 15 % 4;  // remainder = 3
  1. ++ accomplishes the operation of increasing by 1 by itself
int x = 1;
int y= x++;

as similar principle, -- apply the compuation of decreasing by 1 by itself.

int x = 1;
int y= x--;

--x and ++x mean that the final result is returned affter these operation have finished.
3. The sizeof operator is a compile-time unary operator that returns the size (in bytes) of a variable, data type, or expression.

sizeof(type)
sizeof(expression)
sizeof variable_name

loops

  • Executes a block of code as long as a condition is true.
int i = 0;
while (i < 5) {printf("%d ", i);i++;
}
// Output: 0 1 2 3 4
  • do-while loop:as similar as while,the condition of loop which is true decides to continue loop but there is an obvious difference that the do-while loop inspects the loop’s condition after finishing the block of the loop one time ,no matter whether the condition was met .
int i = 0;
do {printf("%d ", i);i++;
} while (i < 5);
// Output: 0 1 2 3 4
  • for Loop
for (int i = 0; i < 5; i++) {printf("%d ", i);
}
// Output: 0 1 2 3 4
  • break - Exits the loop immediately
for (int i = 0; i < 10; i++) {if (i == 5) break;printf("%d ", i);
}
// Output: 0 1 2 3 4
  • continue - Skips the current iteration and continues with the next
for (int i = 0; i < 5; i++) {if (i == 2) continue;printf("%d ", i);
}
// Output: 0 1 3 4

references

  1. deepseek
http://www.dtcms.com/a/293662.html

相关文章:

  • JavaWeb笔记12
  • 硬件基础 -- 信号完整性
  • ESP32-S3学习笔记<4>:I2C的应用
  • 0基础法考随手笔记 02(刑诉法专题04 辩护与代理)
  • 如何用 Kafka + Redis + 线程池搭建高吞吐异步消息处理架构
  • TwoPhaseIterator 两阶段验证
  • Fastdds中的端口号计算
  • 基于 XGBoost 与 SHAP 的医疗自动化办公与可视化系统(下)
  • 在React中,函数式组件和类组件各有优缺点
  • 射频信号(大宽高比)时频图目标检测anchors配置(下)
  • 分布式任务调度实战:XXL-JOB与Elastic-Job深度解析
  • ZKmall开源商城微服务架构实战:Java 商城系统的模块化拆分与通信之道
  • 【音视频学习】五、深入解析视频技术中的像素格式:颜色空间、位深度、存储布局
  • TR-FRET(时间分辨荧光能量共振转移)在药物研发中的热门应用简介
  • 【解决vmware ubuntu不小心删boot分区,进不去系统】
  • 在 Ubuntu 上将 Docker 降级到版本 25.0.5 (二) 降低版本,涉及兼容性问题
  • 在离线 Ubuntu 22.04机器上运行 ddkj_portainer-cn 镜像 其他相关操作也可以复刻 docker
  • centos 配置docker
  • java通过com进行pdf转换docx丢失
  • mongodb的备份和还原(精简)
  • LeetCode11~20题解
  • Visual Studio中部署PaddleOCRv5 (借助ncnn框架)
  • 如何Visual Studio 的配置从 Qt-Debug 切换到 x64-Debug
  • ESP32的ADF详解:5. Streams的API
  • 聊聊 Flutter 在 iOS 真机 Debug 运行出现 Timed out *** to update 的问题
  • GEMINUS 和 Move to Understand a 3D Scene
  • Redis的key过期策略
  • 4.3 激活函数的目的
  • LLM 幻觉一般是由于什么产生的,在模型什么部位产生
  • 计算机组成原理——数据的表示和运算2