{"id":1251,"date":"2019-01-08T13:00:48","date_gmt":"2019-01-08T04:00:48","guid":{"rendered":"https:\/\/www.bold.ne.jp\/engineer-club\/?p=1251"},"modified":"2025-09-17T14:19:39","modified_gmt":"2025-09-17T05:19:39","slug":"c-if","status":"publish","type":"post","link":"https:\/\/www.bold.ne.jp\/engineer-club\/c-if","title":{"rendered":"C\u8a00\u8a9e\u306eif\u6587\u3068\u306f\uff1f\u6761\u4ef6\u5206\u5c90\u51e6\u7406\u306e\u57fa\u672c\u3068\u306a\u308bif\u6587\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306b\u304a\u3044\u3066\u3001\u6761\u4ef6\u5206\u5c90\u51e6\u7406\u306f\u5fc5\u8981\u4e0d\u53ef\u6b20\u306a\u51e6\u7406\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>C\u8a00\u8a9e\u306b\u304a\u3044\u3066\u3001\u6761\u4ef6\u5206\u5c90\u306e\u5236\u5fa1\u6587\u306f\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001<strong>\u6761\u4ef6\u5206\u5c90\u51e6\u7406\u306e\u57fa\u672c\u3068\u306a\u308bif\u6587\u306e\u4f7f\u3044\u65b9<\/strong>\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#Cif\">\uff11\uff0e\u3010C\u8a00\u8a9e\u3011if\u6587\u3068\u306f<\/a><ul><li><a href=\"#-if\">\uff11-\uff11\uff0eif\u6587\u3068\u306f<\/a><\/li><li><a href=\"#i\">\uff11-\uff12\uff0e\u6761\u4ef6\u5f0f\u306f\u771f\u507d\u5024\u3067\u5224\u5b9a\u3059\u308b<\/a><\/li><li><a href=\"#i-2\">\uff11-\uff13\uff0e\u95a2\u4fc2\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u305f\u6761\u4ef6\u5f0f<\/a><\/li><\/ul><\/li><li><a href=\"#Cif-2\">\uff12\uff0e\u3010C\u8a00\u8a9e\u3011\u591a\u5206\u5c90\u306eif\u6587<\/a><ul><li><a href=\"#-else_if\">\uff12-\uff11\uff0eelse if\u6587<\/a><\/li><li><a href=\"#-if-2\">\uff12-\uff12\uff0e\u8907\u6570\u6761\u4ef6\u306eif\u6587<\/a><\/li><\/ul><\/li><li><a href=\"#i-3\">\uff13\uff0e\u3055\u3044\u3054\u306b<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Cif\">\uff11\uff0e\u3010C\u8a00\u8a9e\u3011if\u6587\u3068\u306f<\/span><\/h2>\n<h3><span id=\"-if\">\uff11-\uff11\uff0eif\u6587\u3068\u306f<\/span><\/h3>\n<p>if\u6587\u306f\u6761\u4ef6\u5206\u5c90\u51e6\u7406\u3092\u884c\u3046\u305f\u3081\u306e\u547d\u4ee4\u6587\u3067\u3059\u3002<\/p>\n<p>\u5177\u4f53\u7684\u306b\u306f\u3001\u300c\u6761\u4ef6A\u304c\u6210\u7acb\u3059\u308b\u5834\u5408\u3001\u51e6\u7406A\u00b4\u3092\u3059\u308b\u300d\u3068\u3044\u3063\u305f\u3053\u3068\u3092\u3055\u305b\u308b\u305f\u3081\u306e\u624b\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001if\u6587\u306e\u8a18\u8ff0\u65b9\u6cd5\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>if (\u6761\u4ef6\u5f0f)<\/p>\n<p>{<\/p>\n<p>\u00a0 \uff08\u6761\u4ef6\u5f0f\u304c\u6210\u7acb\u3059\u308b\u5834\u5408\u306e\u51e6\u7406\u3092\u8a18\u8ff0\uff09<\/p>\n<p>}<\/p>\n<\/blockquote>\n<h3><span id=\"i\">\uff11-\uff12\uff0e\u6761\u4ef6\u5f0f\u306f\u771f\u507d\u5024\u3067\u5224\u5b9a\u3059\u308b<\/span><\/h3>\n<p>if\u6587\u306b\u304a\u3051\u308b\u6761\u4ef6\u5f0f\u306f\u771f\u507d\u5024\u3067\u5224\u5b9a\u3055\u308c\u3001\u771f\u306e\u5834\u5408\u306b\u6761\u4ef6\u304c\u6210\u7acb\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u203b\uff09<\/p>\n<p>\u5c1a\u3001\u771f\u507d\u5024\u306f\u6b21\u306e\u3088\u3046\u306b\u5224\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u771f\uff1a\u2260\uff10\u3000\uff08\u30bc\u30ed\u3067\u306a\u3044\uff09<\/li>\n<li>\u507d\uff1a\uff10\u3000\u3000\uff08\u30bc\u30ed\u3067\u3042\u308b\uff09<\/li>\n<\/ul>\n<p>\u203b\u3000if\u6587\u306b\u9650\u3089\u305a\u3001C\u8a00\u8a9e\u3067\u6271\u3046\u6761\u4ef6\u5f0f\u5168\u822c\u304c\u771f\u507d\u5024\u3067\u5224\u5b9a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<h6>\u3010\u4f8b\uff11\uff0d\uff11\u3011<\/h6>\n<pre class=\"prettyprint lang:default decode:true\">int a = 0;\r\nint b = 1;\r\n\r\nif(a)\r\n{\r\n    printf(\u201c\u5909\u6570a\u306f\u771f\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}\r\n\r\nif(b)\r\n{\r\n    printf(\u201c\u5909\u6570b\u306f\u771f\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u306e\u7d50\u679c\u306f\u3001\u300c\u5909\u6570b\u306f\u771f\u3067\u3059\u3002\u300d\u3060\u3051\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u6b21\u306b\u5426\u5b9a\uff08\uff5e\u3067\u306a\u3044\uff09\u3092\u610f\u5473\u3059\u308b\u6761\u4ef6\u5f0f\u306e\u8a18\u8ff0\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<p>\u6761\u4ef6\u5f0f\u306e\u5148\u982d\u306b\u3001\u300c!\u300d\u3092\u4ed8\u3051\u308b\u3053\u3068\u3067\u3001\u5426\u5b9a\u3092\u610f\u5473\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h6>\u3010\u4f8b\uff11\uff0d\uff12\u3011<\/h6>\n<pre class=\"prettyprint lang:default decode:true\">int a = 0;\r\nint b = 1;\r\n\r\nif(!a)\r\n{\r\n    printf(\u201c\u5909\u6570a\u306f\u507d\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}\r\n\r\nif(!b)\r\n{\r\n    printf(\u201c\u5909\u6570b\u306f\u507d\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u306e\u7d50\u679c\u306f\u3001\u300c\u5909\u6570a\u306f\u507d\u3067\u3059\u3002\u300d\u3060\u3051\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3><span id=\"i-2\">\uff11-\uff13\uff0e\u95a2\u4fc2\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u305f\u6761\u4ef6\u5f0f<\/span><\/h3>\n<p>\u95a2\u4fc2\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u4f7f\u3044\u3084\u3059\u3044\u6761\u4ef6\u5f0f\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u95a2\u4fc2\u6f14\u7b97\u5b50\u306e\u7a2e\u985e\u3092\u4e0b\u8868\u306b\u8a18\u3057\u307e\u3059\u3002<\/p>\n<table border=\"1\" style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 12.6833%; height: 24px; text-align: center; border-color: #000000; background-color: #9cf590;\">\u9805\u756a<\/td>\n<td style=\"width: 18.8417%; height: 24px; text-align: center; border-color: #000000; background-color: #9cf590;\">\u6f14\u7b97\u5b50<\/td>\n<td style=\"width: 25.4886%; height: 24px; text-align: center; border-color: #000000; background-color: #9cf590;\">\u610f\u5473<\/td>\n<td style=\"width: 42.9864%; height: 24px; text-align: center; border-color: #000000; background-color: #9cf590;\">\u4f8b<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 12.6833%; height: 24px; text-align: center; border-color: #000000;\">1<\/td>\n<td style=\"width: 18.8417%; height: 24px; text-align: center; border-color: #000000;\">\uff1d\uff1d<\/td>\n<td style=\"width: 25.4886%; height: 24px; text-align: center; border-color: #000000;\">\u7b49\u3057\u3044<\/td>\n<td style=\"width: 42.9864%; height: 24px; text-align: center; border-color: #000000;\">if( a == 0)\u00a0 \/\/ a\u304c0\u3067\u3042\u308b<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 12.6833%; height: 24px; text-align: center; border-color: #000000;\">2<\/td>\n<td style=\"width: 18.8417%; height: 24px; text-align: center; border-color: #000000;\">\uff01\uff1d<\/td>\n<td style=\"width: 25.4886%; height: 24px; text-align: center; border-color: #000000;\">\u7b49\u3057\u304f\u306a\u3044<\/td>\n<td style=\"width: 42.9864%; height: 24px; text-align: center; border-color: #000000;\">if( a != 0)\u00a0 \/\/ a\u304c0\u3067\u306a\u3044<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 12.6833%; height: 24px; text-align: center; border-color: #000000;\">3<\/td>\n<td style=\"width: 18.8417%; height: 24px; text-align: center; border-color: #000000;\">\uff1e<\/td>\n<td style=\"width: 25.4886%; height: 24px; text-align: center; border-color: #000000;\">\u3088\u308a\u5927\u304d\u3044<\/td>\n<td style=\"width: 42.9864%; height: 24px; text-align: center; border-color: #000000;\">if( a &gt; 0) \/\/ a\u304c0\u3088\u308a\u5927\u304d\u3044<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 12.6833%; height: 24px; text-align: center; border-color: #000000;\">4<\/td>\n<td style=\"width: 18.8417%; height: 24px; text-align: center; border-color: #000000;\">&lt;<\/td>\n<td style=\"width: 25.4886%; height: 24px; text-align: center; border-color: #000000;\">\u3088\u308a\u5c0f\u3055\u3044<\/td>\n<td style=\"width: 42.9864%; height: 24px; text-align: center; border-color: #000000;\">if( a &lt; 0) \/\/ a\u304c0\u3088\u308a\u5c0f\u3055\u3044<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 12.6833%; height: 24px; text-align: center; border-color: #000000;\">5<\/td>\n<td style=\"width: 18.8417%; height: 24px; text-align: center; border-color: #000000;\">&gt;=<\/td>\n<td style=\"width: 25.4886%; height: 24px; text-align: center; border-color: #000000;\">\u4ee5\u4e0a<\/td>\n<td style=\"width: 42.9864%; height: 24px; text-align: center; border-color: #000000;\">if( a &gt;= 0) \/\/ a\u304c0\u4ee5\u4e0a\u3067\u3042\u308b<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 12.6833%; height: 24px; text-align: center; border-color: #000000;\">6<\/td>\n<td style=\"width: 18.8417%; height: 24px; text-align: center; border-color: #000000;\">&lt;=<\/td>\n<td style=\"width: 25.4886%; height: 24px; text-align: center; border-color: #000000;\">\u4ee5\u4e0b<\/td>\n<td style=\"width: 42.9864%; height: 24px; text-align: center; border-color: #000000;\">if( a &lt;= 0) \/\/ a\u304c0\u4ee5\u4e0b\u3067\u3042\u308b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u305f\u6761\u4ef6\u5f0f\u306e\u4f8b\u3092\u4ee5\u4e0b\u306b\u8a18\u3057\u307e\u3059\u3002<\/p>\n<h6>\u3010\u4f8b\uff11\uff0d\uff13\u3011<\/h6>\n<pre class=\"prettyprint lang:default decode:true\">if(num%2 == 0)\r\n{\r\n    printf(\u201c\u5909\u6570num\u306f\u5076\u6570\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u306f\u3001\u5909\u6570num\u30922\u3067\u5272\u3063\u305f\u4f59\u308a\u304c0\u306e\u5834\u5408\u306b\u3001\u5909\u6570num\u304c\u5076\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u51fa\u529b\u3057\u307e\u3059\u3002\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u5076\u6570\u306e\u5834\u5408\u306b\u3057\u304b\u51fa\u529b\u3055\u308c\u307e\u305b\u3093\u304c\u3001\u5947\u6570\u306e\u5834\u5408\u306b\u3082\u7d50\u679c\u3092\u51fa\u529b\u3057\u305f\u3044\u3067\u3059\u3088\u306d\u3002if\u6587\u3092\uff12\u3064\u4e26\u3079\u3066\u3082\u5b9f\u73fe\u3059\u308b\u3053\u3068\u306f\u53ef\u80fd\u3067\u3059\u304c\u3001else\u6587\u3092\u4f7f\u7528\u3059\u308b\u3068\u30b9\u30c3\u30ad\u30ea\u8a18\u8ff0\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>else\u6587\u3092\u4f7f\u7528\u3057\u305f\u6761\u4ef6\u5f0f\u306e\u4f8b\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h6>\u3010\u4f8b\uff11\uff0d\uff14\u3011<\/h6>\n<pre class=\"prettyprint lang:default decode:true\">if(num%2 == 0)\r\n{\r\n    printf(\u201c\u5909\u6570num\u306f\u5076\u6570\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}\r\nelse\r\n{\r\n    printf(\u201c\u5909\u6570num\u306f\u5947\u6570\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}<\/pre>\n<p>\u3053\u308c\u3067\u5947\u6570\u306e\u5834\u5408\u306b\u3082\u51fa\u529b\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5c1a\u3001if\u6587\u306f\u771f\u507d\u5024\u3067\u8868\u3059\u305f\u3081\u3001\u4e0a\u8a18\u306e\u4f8b\u306f\u6b21\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<h6>\u3010\u4f8b\uff11\uff0d\uff15\u3011<\/h6>\n<pre class=\"prettyprint lang:default decode:true\">if(!num%2)\r\n{\r\n    printf(\u201c\u5909\u6570num\u306f\u5076\u6570\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}\r\nelse\r\n{\r\n    printf(\u201c\u5909\u6570num\u306f\u5947\u6570\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}<\/pre>\n<p>\u306a\u305c\u540c\u3058\u306b\u306a\u308b\u304b\u3068\u3044\u3046\u3068\u3001num%2\u306e\u7d50\u679c\u304c0\uff08\u507d\uff09\u306b\u306a\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u6b21\u306e\u3088\u3046\u306b\u3057\u3066\u3082\u540c\u3058\u7d50\u679c\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h6>\u3010\u4f8b\uff11\uff0d\uff16\u3011<\/h6>\n<pre class=\"prettyprint lang:default decode:true\">if(num%2)\r\n{\r\n    printf(\u201c\u5909\u6570num\u306f\u5947\u6570\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}\r\nelse\r\n{\r\n    printf(\u201c\u5909\u6570num\u306f\u5076\u6570\u3067\u3059\u3002\\n\u201d); \/\/ \u51e6\u7406\r\n}<\/pre>\n<p>\u3053\u3061\u3089\u306f\u3001num%2\u306e\u7d50\u679c\u304c1\uff08\u771f\uff09\u306a\u306e\u3067\u3001\u51fa\u529b\u3059\u308b\u6587\u5b57\u5217\u3092\u5165\u308c\u66ff\u3048\u308b\u3053\u3068\u3067\u540c\u3058\u51e6\u7406\u3092\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<h2><span id=\"Cif-2\">\uff12\uff0e\u3010C\u8a00\u8a9e\u3011\u591a\u5206\u5c90\u306eif\u6587<\/span><\/h2>\n<p><strong>\u00a0<\/strong>\u6761\u4ef6\u5206\u5c90\u3092\u3055\u305b\u308b\u5834\u5408\u3001\u5fc5\u305a\u3057\u3082\u5206\u5c90\u304c\uff12\u3064\u3068\u306f\u9650\u308a\u307e\u305b\u3093\u3057\u3001\u6761\u4ef6\u3082\uff11\u3064\u3068\u306f\u9650\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u672c\u7ae0\u3067\u306f\u3001\uff13\u3064\u4ee5\u4e0a\u306b\u5206\u5c90\u3055\u305b\u308b\u5834\u5408\u3001\u6761\u4ef6\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u306e\u8a18\u8ff0\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h3><span id=\"-else_if\">\uff12-\uff11\uff0eelse if\u6587<\/span><\/h3>\n<p>\uff13\u3064\u4ee5\u4e0a\u306b\u5206\u5c90\u3055\u305b\u305f\u3044\u5834\u5408\u3001else if\u6587\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u8a18\u8ff0\u65b9\u6cd5\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h6>\u3010\u4f8b\uff12\uff0d\uff11\u3011<\/h6>\n<pre class=\"prettyprint lang:default decode:true\">int result = num % 3;\r\n\r\nif(result == 0)\r\n{\r\n    printf(\u201c\u5909\u6570num\u306e3\u306e\u5270\u4f59\u306f0\u3067\u3059\u3002\\n\u201d);\r\n}\r\nelse if(result == 1)\r\n{\r\n    printf(\u201c\u5909\u6570num\u306e3\u306e\u5270\u4f59\u306f1\u3067\u3059\u3002\\n\u201d);\r\n}\r\nelse\r\n{\r\n    printf(\u201c\u5909\u6570num\u306e3\u306e\u5270\u4f59\u306f2\u3067\u3059\u3002\\n\u201d);\r\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u306f\u3001\u5909\u6570num\u30923\u3067\u5272\u3063\u305f\u4f59\u308a\u3067\u5206\u5c90\u3055\u305b\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u305f\u3081\u3001\u7d50\u679c\u306f0\uff5e2\u306e3\u30d1\u30bf\u30fc\u30f3\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u6761\u4ef6\u5206\u5c90\u306e\u9806\u5e8f\u306f\u3001\u8a18\u8ff0\u3057\u3066\u3044\u308b\u9806\u5e8f\u306b\u5f93\u3044\u307e\u3059\u3002\u3053\u306e\u305f\u3081\u3001\u9806\u5e8f\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li>if\u6587<\/li>\n<li>else if\u6587<\/li>\n<li>else\u6587<\/li>\n<\/ol>\n<p>if\u6587\u306f\u5148\u982d\u306e1\u56de\u306e\u307f\u3057\u304b\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002\u307e\u305f\u3001else\u6587\u306fif\u3001else if\u306e\u6761\u4ef6\u4ee5\u5916\u306e\u3082\u306e\u304c\u5165\u308b\u305f\u3081\u3001\u8a18\u8ff0\u9806\u5e8f\u306f\u5fc5\u305a\u6700\u5f8c\u306e1\u3064\u3060\u3051\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\uff14\u3064\u4ee5\u4e0a\u306b\u5206\u5c90\u3055\u305b\u308b\u5834\u5408\u306f\u3069\u3046\u3059\u308c\u3070\u3088\u3044\u304b\u3068\u3044\u3046\u3068\u3001else if\u3092\u8907\u6570\u8a18\u8ff0\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\uff14\u3064\u306b\u5206\u5c90\u3055\u305b\u305f\u4f8b\u3092\u4ee5\u4e0b\u306b\u8a18\u3057\u307e\u3059\u3002<\/p>\n<h6>\u3010\u4f8b\uff12\uff0d\uff12\u3011<\/h6>\n<pre class=\"prettyprint lang:default decode:true\">int result = num % 5;\r\n\r\nif(result == 0)\r\n{\r\n    printf(\u201c\u5909\u6570num\u306e5\u306e\u5270\u4f59\u306f0\u3067\u3059\u3002\\n\u201d);\r\n}\r\nelse if(result == 1)\r\n{\r\n    printf(\u201c\u5909\u6570num\u306e5\u306e\u5270\u4f59\u306f1\u3067\u3059\u3002\\n\u201d);\r\n}\r\nelse if(result == 2)\r\n{\r\n    printf(\u201c\u5909\u6570num\u306e5\u306e\u5270\u4f59\u306f2\u3067\u3059\u3002\\n\u201d);\r\n}\r\nelse\r\n{\r\n    printf(\u201c\u5909\u6570num\u306e5\u306e\u5270\u4f59\u306f3\u307e\u305f\u306f4\u3067\u3059\u3002\\n\u201d);\r\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u30015\u3067\u5272\u3063\u305f\u4f59\u308a\u3067\u5224\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>5\u306e\u5270\u4f59\u306f0\uff5e4\u306e5\u30d1\u30bf\u30fc\u30f3\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u3053\u308c\u3092\uff14\u3064\u306b\u5206\u5c90\u3055\u305b\u3066\u3044\u308b\u305f\u3081\u3001else\u5206\u5c90\u306b\u5165\u308b\u306e\u306f3\u30684\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3><span id=\"-if-2\">\uff12-\uff12\uff0e\u8907\u6570\u6761\u4ef6\u306eif\u6587<\/span><\/h3>\n<p><strong>\u00a0<\/strong>\u8907\u6570\u6761\u4ef6\u3067\u5224\u5b9a\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u6761\u4ef6\u5f0f\u3092\u8ad6\u7406\u6f14\u7b97\u5b50\u3067\u3064\u306a\u304e\u307e\u3059\u3002<\/p>\n<p>\u8ad6\u7406\u6f14\u7b97\u5b50\u306e\u7a2e\u985e\u3092\u4e0b\u8868\u306b\u8a18\u3057\u307e\u3059\u3002<\/p>\n<table border=\"1\" style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.9238%; height: 24px; background-color: #9cf590; border-color: #000000; text-align: center;\">\u9805\u756a<\/td>\n<td style=\"width: 17.8641%; text-align: center; height: 24px; background-color: #9cf590; border-color: #000000;\">\u6f14\u7b97\u5b50<\/td>\n<td style=\"width: 15.8113%; text-align: center; height: 24px; background-color: #9cf590; border-color: #000000;\">\u610f\u5473<\/td>\n<td style=\"width: 55.4008%; text-align: center; height: 24px; background-color: #9cf590; border-color: #000000;\">\u4f8b<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.9238%; text-align: center; height: 24px; border-color: #000000;\">1<\/td>\n<td style=\"width: 17.8641%; text-align: center; height: 24px; border-color: #000000;\">\uff06\uff06<\/td>\n<td style=\"width: 15.8113%; text-align: center; height: 24px; border-color: #000000;\">\u4e14\u3064<\/td>\n<td style=\"width: 55.4008%; text-align: center; height: 24px; border-color: #000000;\">if(a &gt;= 0) &amp;&amp; (a &gt;= 3)\u00a0 \/\/ a\u304c0\u4ee5\u4e0a3\u4ee5\u4e0b\u3067\u3042\u308b<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.9238%; text-align: center; height: 24px; border-color: #000000;\">2<\/td>\n<td style=\"width: 17.8641%; text-align: center; height: 24px; border-color: #000000;\">\uff5c\uff5c<\/td>\n<td style=\"width: 15.8113%; text-align: center; height: 24px; border-color: #000000;\">\u53c8\u306f<\/td>\n<td style=\"width: 55.4008%; text-align: center; height: 24px; border-color: #000000;\">if(a == 0) || (a == 10) \/\/ a\u304c0\u307e\u305f\u306f10\u3067\u3042\u308b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u3067\u306f\u3001\u8ad6\u7406\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3057\u305fif\u6587\u306e\u4f7f\u7528\u4f8b\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u3001\u9805\u756a\uff11\u306e\uff21\uff2e\uff24\u6761\u4ef6\u3092\u5229\u7528\u3057\u305f\u4f8b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h6>\u3010\u4f8b\uff12\uff0d\uff13\u3011<\/h6>\n<pre class=\"prettyprint lang:default decode:true\">unsigned int age;  \/\/ \u5e74\u9f62\u3092\u8868\u3059\u5909\u6570\r\n\/\/----------\u4e2d\u7565-----------\r\nif(age &lt; 7)  \/\/ \uff17\u6b73\u672a\u6e80\r\n{\r\n    printf(\u201c\u672a\u5c31\u5b66\u5150\u3001\u307e\u305f\u306f\u5c0f\u5b661\u5e74\u751f\\n\u201d);\r\n}\r\nelse if((age &gt;= 7) &amp;&amp; (age &lt;= 11)) \/\/ \uff17\u6b73\u4ee5\u4e0a\uff11\uff11\u6b73\u4ee5\u4e0b\r\n{\r\n    printf(\u201c\u5c0f\u5b66\u751f\\n\u201d);\r\n}\r\nelse if(age == 12) \/\/ \uff11\uff12\u6b73\r\n{\r\n    printf(\u201c\u5c0f\u5b666\u5e74\u751f\u3001\u307e\u305f\u306f\u4e2d\u5b661\u5e74\u751f\\n\u201d);\r\n}\r\nelse if((age &gt;= 13) &amp;&amp; (age &lt;= 14)) \/\/ \uff11\uff13\u6b73\u4ee5\u4e0a\uff11\uff14\u6b73\u4ee5\u4e0b\r\n{\r\n    printf(\u201c\u4e2d\u5b66\u751f\\n\u201d);\r\n}\r\nelse \/\/ \u305d\u306e\u4ed6\r\n{\r\n    printf(\u201c\u4e2d\u5b663\u5e74\u751f\u4ee5\u4e0a\\n\u201d);\r\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u306f\u3001\u5e74\u9f62\u3092\u8868\u3059\u5909\u6570<span>age<\/span>\u3092\u5143\u306b\u5206\u5c90\u3055\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001\u9805\u756a\uff12\u306e\uff2f\uff32\u6761\u4ef6\u3092\u4f7f\u7528\u3057\u305f\u4f8b\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">unsigned int num;  \/\/ \u6570\u5b57\u3092\u8868\u3059\u5909\u6570\r\n\/\/----------\u4e2d\u7565-----------\r\n\r\nif((num % 2 == 0) || ( num % 3 == 0))\r\n{\r\n    printf(\u201c\u5909\u6570num\u306f\uff12\u3001\u307e\u305f\u306f\uff13\u306e\u500d\u6570\u3067\u3059\u3002\\n\u201d);\r\n}\r\nelse\r\n{\r\n    printf(\u201c\u5909\u6570num\u306f\uff12\u306e\u500d\u6570\u3067\u3082\uff13\u306e\u500d\u6570\u3067\u3082\u3042\u308a\u307e\u305b\u3093\u3002\\n\u201d);\r\n}<\/pre>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u6ce8\u76ee\u3057\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u306e\u306f\u3001\uff2f\uff32\u6761\u4ef6\u306e<span>Else<\/span>\u7bc0\u304c\uff21\uff2e\uff24\u6761\u4ef6\u306b\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<h2><span id=\"i-3\">\uff13\uff0e\u3055\u3044\u3054\u306b<\/span><\/h2>\n<p>\u4ee5\u4e0a\u3001C\u8a00\u8a9e\u306b\u304a\u3051\u308bif\u6587\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3092\u307e\u3068\u3081\u307e\u3057\u305f\u3002C\u8a00\u8a9e\u3092\u6271\u3046\u4e0a\u3067if\u6587\u306f\u5fc5\u305a\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u6761\u4ef6\u5f0f\u306fif\u6587\u4ee5\u5916\u306e\u547d\u4ee4\u6587\u3067\u3082\u4f7f\u7528\u3057\u307e\u3059\u3002\u306a\u306e\u3067\u3001C\u8a00\u8a9e\u3092\u899a\u3048\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u308b\u65b9\u306b\u306f\u662f\u975e\u899a\u3048\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u5c1a\u3001\u672c\u8a18\u4e8b\u5185\u3067\u4f8b\u3068\u3057\u3066\u4f7f\u7528\u3057\u305f\u30b3\u30fc\u30c9\u306f\u3042\u304f\u307e\u3067\u4f7f\u3044\u65b9\u3092\u793a\u3059\u305f\u3081\u306e\u3082\u306e\u3067\u3042\u308b\u305f\u3081\u3001\u5b9f\u52d9\u3067\u306e\u4f7f\u7528\u65b9\u6cd5\u306b\u5408\u308f\u306a\u3044\u3082\u306e\u3082\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306b\u304a\u3044\u3066\u3001\u6761\u4ef6\u5206\u5c90\u51e6\u7406\u306f\u5fc5\u8981\u4e0d\u53ef\u6b20\u306a\u51e6\u7406\u306b\u306a\u308a\u307e\u3059\u3002 C\u8a00\u8a9e\u306b\u304a\u3044\u3066\u3001\u6761\u4ef6\u5206\u5c90\u306e\u5236\u5fa1\u6587\u306f\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u6761\u4ef6\u5206\u5c90\u51e6\u7406\u306e\u57fa\u672c\u3068\u306a\u308bif\u6587\u306e\u4f7f\u3044\u65b9\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u76ee\u6b21\uff11\uff0e\u3010C\u8a00\u8a9e\u3011i [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":975,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/1251"}],"collection":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/comments?post=1251"}],"version-history":[{"count":7,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/1251\/revisions"}],"predecessor-version":[{"id":5732,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/1251\/revisions\/5732"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media\/975"}],"wp:attachment":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media?parent=1251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/categories?post=1251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}