小程序 || 语句_C ++条件语句| 查找输出程序| 套装2
小程序 || 語句
Program 1:
程序1:
#include <iostream> #include <stdio.h> using namespace std;int main() {int num = 0;num = printf("%d ", printf("%d ", printf("ABC")));if (num == 2) {cout << "INDIA";}else if (num == 3) {cout << "AUSTRALIA";}else {cout << "CHINA";}return 0; }Output:
輸出:
ABC3 2 INDIAExplanation:
說明:
The above program will print "ABC3 2 INDIA" on the console screen.
上面的程序將在控制臺屏幕上打印“ ABC3 2 INDIA” 。
The printf() function returns the total number of characters printed on the console screen.
printf()函數返回控制臺屏幕上打印的字符總數。
Execution of the program step by step:
逐步執行程序:
num = printf("%d ",printf("%d ",printf("ABC")));In this statement the innermost printf() will be executed first and prints "ABC" and returns 3, then the second printf() prints "3 " and returns 2 because 3 and space are two characters, and then the last outermost printf() will be executed and prints "2 " and returns 2 that is assigned to num variable.
在此語句中,最里面的printf()將首先執行并打印“ ABC”并返回3 ,然后第二個printf()打印“ 3”并返回2,因為3和空格是兩個字符,然后是最后一個最外面的printf()將被執行并輸出“2”,并返回2分配給num變量。
The num variable contains 2 then the first condition will be true and it will print "INDIA".
num變量包含2,那么第一個條件為true,它將輸出“ INDIA” 。
Then the final output will be?"ABC3 2 INDIA".
然后,最終輸出將為“ ABC3 2 INDIA” 。
Program 2:
程式2:
#include <iostream> #include <stdio.h> using namespace std;int main() {int num = 0;if (EOF) {cout << "INDIA";}else if (NULL) {cout << "AUSTRALIA";}else {cout << "USA";}return 0; }Output:
輸出:
INDIAExplanation:
說明:
The above program will print "INDIA" on the console screen. Because the value of the EOF macro is -1. And any non-zero value is considered as a true for if conditions, this, the first condition will be true and it will print "INDIA" on the console screen.
上面的程序將在控制臺屏幕上打印“ INDIA” 。 因為EOF宏的值為-1 。 如果條件為條件,則任何非零值都將被視為true,則第一個條件將為true,并將在控制臺屏幕上顯示“ INDIA” 。
Recommended posts
推薦的帖子
C++ Conditional Statements | Find output programs | Set 1
C ++條件語句| 查找輸出程序| 套裝1
C++ Reference Variable| Find output programs | Set 1
C ++參考變量| 查找輸出程序| 套裝1
C++ Reference Variable| Find output programs | Set 2
C ++參考變量| 查找輸出程序| 套裝2
C++ const Keyword | Find output programs | Set 1
C ++ const關鍵字| 查找輸出程序| 套裝1
C++ const Keyword | Find output programs | Set 2
C ++ const關鍵字| 查找輸出程序| 套裝2
C++ Operators | Find output programs | Set 1
C ++運算符| 查找輸出程序| 套裝1
C++ Operators | Find output programs | Set 2
C ++運算符| 查找輸出程序| 套裝2
C++ Switch Statement | Find output programs | Set 1
C ++轉換語句| 查找輸出程序| 套裝1
C++ Switch Statement | Find output programs | Set 2
C ++轉換語句| 查找輸出程序| 套裝2
C++ goto Statement | Find output programs | Set 1
C ++ goto語句| 查找輸出程序| 套裝1
C++ goto Statement | Find output programs | Set 2
C ++ goto語句| 查找輸出程序| 套裝2
C++ Looping | Find output programs | Set 1
C ++循環| 查找輸出程序| 套裝1
C++ Looping | Find output programs | Set 2
C ++循環| 查找輸出程序| 套裝2
C++ Looping | Find output programs | Set 3
C ++循環| 查找輸出程序| 套裝3
C++ Looping | Find output programs | Set 4
C ++循環| 查找輸出程序| 套裝4
C++ Looping | Find output programs | Set 5
C ++循環| 查找輸出程序| 套裝5
翻譯自: https://www.includehelp.com/cpp-tutorial/conditional-statements-find-output-programs-set-2.aspx
小程序 || 語句
總結
以上是生活随笔為你收集整理的小程序 || 语句_C ++条件语句| 查找输出程序| 套装2的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 16位的数字高字节和低字节_掩盖8位数字
- 下一篇: 计算机硬盘正在工作应特别注意避免,初级计