<\/span><\/h2>\n\n\n\n\/\/ C Program To Find the Greatest Among Three Numbers\n#include <stdio.h>\nint main(){\n int a, b, c;\n \n \/\/ Asking for Input\n printf(\"Enter Three Numbers: \");\n scanf(\"%d %d %d\", &a, &b, &c);\n \n \/\/ logic\n if ((a > b) && (a > c))\n printf(\"%d is the largest number.\", a);\n else if ((b > a) && (b > c))\n printf(\"%d is the largest number.\", b);\n else \n printf(\"%d is the largest number.\", c);\n \n return 0; \n}\n<\/pre>\n\n\n\nOutput<\/strong><\/p>\n\n\n\nEnter Three Numbers: 3 5 7\r\n7 is the largest number.\r<\/code><\/pre>\n\n\n\n<\/span>How Does This Program Work ?<\/strong><\/span><\/h2>\n\n\n\n int a, b, c;<\/strong>\r<\/code><\/pre>\n\n\n\nIn this program, we have declared three int variable names as a<\/strong>, b<\/strong> and c<\/strong> respectively.<\/p>\n\n\n\n \/\/ Asking for Input\r\n printf(\"Enter Three Numbers: \");\r\n scanf(\"%d %d %d\", &a, &b, &c);\r<\/strong><\/code><\/pre>\n\n\n\nThen, the user is asked to enter the three numbers. The value of these three numbers will be stored in a<\/strong>, b<\/strong> and c<\/strong> variables.<\/p>\n\n\n\n \/\/ logic\r\n if ((a > b) && (a > c))\r\n printf(\"%d is the largest number.\", a);\r\n else if ((b > a) && (b > c))\r\n printf(\"%d is the largest number.\", b);\r\n else \r\n printf(\"%d is the largest number.\", c);<\/strong>\r<\/code><\/pre>\n\n\n\nFinally, a simple logic is used in this program to get the desirable output. If a<\/strong> is greater than both b<\/strong> and c<\/strong> , then clearly a<\/strong> is the greatest.<\/p>\n\n\n\nIf b<\/strong> is greater than both a<\/strong> and c<\/strong>, then b<\/strong> will be the greatest of the three.<\/p>\n\n\n\nAnd if neither of the above conditions are true, then automatically c<\/strong> will be the largest number.<\/p>\n\n\n\nSome used terms are as follow:\u00a0<\/p>\n\n\n\n
#include <stdio.h><\/strong> – In the first line we have used #include, it is a preprocessor command that tells the compiler to include the contents of the stdio.h(standard input and output) file in the program. <\/p>\n\n\n\nThe stdio.h <\/strong>is a file which contains input and output functions like scanf()<\/strong> and printf()<\/strong> to take input and display output respectively. <\/p>\n\n\n\nInt main()<\/strong> – Here main() is the function name and int is the return type of this function. The Execution of any Programming written in C language begins with main() function. <\/p>\n\n\n\nscanf()<\/strong> – scanf() function is used to take input from the user. <\/p>\n\n\n\nprintf()<\/strong> – printf() function is used to display and print the string under the quotation to the screen. <\/p>\n\n\n\nIf. . . else <\/strong>– An if statement can be followed by an optional else statement, which executes when the Boolean expression is false. If Statement executes when the Boolean expression is True. <\/p>\n\n\n\n&&<\/strong> – It is called Logical AND Operator. If both of the statements are non-zero, then the condition becomes true. <\/p>\n\n\n\n\/\/ <\/strong>– Used for Commenting in C.\u00a0<\/p>\n\n\n\n<\/span>Conclusion<\/strong><\/span><\/h2>\n\n\n\nI hope after going through this tutorial, you understand how to find the largest number among three numbers.<\/p>\n\n\n\n
If you have any doubt regarding the topic, feel free to contact us in the Comment Section. We will be delighted to help you.<\/p>\n","protected":false},"excerpt":{"rendered":"
In this post, you will learn to find the largest number among three numbers.<\/p>\n","protected":false},"author":2,"featured_media":4021,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[167,294],"tags":[222,241,240,206],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.codingbroz.com\/wp-content\/uploads\/2021\/08\/c-program-to-find-the-largest-number-among-three-numbers-codingbroz.png","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/posts\/4019"}],"collection":[{"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/comments?post=4019"}],"version-history":[{"count":2,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/posts\/4019\/revisions"}],"predecessor-version":[{"id":4022,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/posts\/4019\/revisions\/4022"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/media\/4021"}],"wp:attachment":[{"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/media?parent=4019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/categories?post=4019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingbroz.com\/wp-json\/wp\/v2\/tags?post=4019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}