C program to find a largest number among three numbers in Tamil

 How to write a c program to find big number among three numbers

இன்றைக்கு மூன்று எண்களிலிருந்து பெரிய எண்ணை கண்டுபிடிப்பதற்கு ஒரு c program எப்படி எழுதுவது  என அறிந்துகொள்ளலாம்.

Program 

#include<stdio.h>

int main()
{
int a,b,c;
printf("\nEnter the three numbers:\n");
scanf("%d %d %d",&a,&b,&c);
if(a>b&&a>c)
{
printf("%d is largest number",a);
}
else if(b>a&&b>c)
{
printf("%d is largest number",b);
}
else if(c>a&&c>b)
{
printf("%d is largest number", c);
}
return 0;
}

OUTPUT 

Enter the three numbers:

5 7 6

7 is largest number

விளக்கம்:

  1.                  இந்த program-ல் <stdio.h> என்பது முதலில் input மற்றும் output ஐ access செய்யும் ஒரு header file.       < stdio.h> கொடுத்தால் மட்டும் தான் input ஆன scanf functionனும் output ஆன printf functionனும் work ஆகும். இல்லை எனில் errors வரும்.
  2. அடுத்தபடியாக மூன்று எண்களுக்காக(numbers) மூன்று variables a, b மற்றும் cயை declare செய்கிறோம்.
          int a,b,c;

       3.பிறகு அந்த மூன்று எண்களையும்                input ஆக scanf function மூலமாக                  run  timeல் 
       printf("\nEnter the three numbers:\n");
      scanf("%d %d %d",&a,&b,&c);umbers:\n");
      இப்படி வாங்குகிறோம்.

     4.இதற்கு அடுத்து if use செய்கிறோம்.            ஒரு decison making statement.if                      statementல் பல types இருக்கிறது.               ஆனால் இந்த programமிற்காக நான்           else if ladder statementஐ use                             செய்திருக்கிறேன்.

இப்போது முதல் conditionஐ எடுத்துக் கொள்வோம்.
if(a>b&&a>c)
இப்போது program கொடுக்கப்பட்ட valueகளை வைத்து இந்த  condition சரியா அல்லது தவறா என test செய்யும்.
a>b எனும் போது a என்னும் variable கொடுக்கப்பட்டிருக்கும்  number  bஐ விட பெரியதா என check செய்யும். 
a>c எனும் போது a ஆனது cஐ விட பெரிய எண்ணா என test செய்யும்.
நடுவில் உள்ள && (AND) logical operator 
a>b மற்றும் a>c ஆகிய இரு conditionகளும் சரி எனில் பின் வரும் prinf statementஐ excute செய்யும். இரு conditionகளில் ஒன்றோ அல்லது இரண்டுமே தவறு எனில் printf statementஐ skip செய்து விட்டு அடுத்த conditionஐ excute செய்ய ஆரம்பிக்கும். இதே போல் அடுத்தடுத்த conditionகள் தவறு எனில் அதற்கு அடுத்த conditionஐ
excute பண்ணும்.


Comments

Popular posts from this blog

Python Program: Generating the Fibonacci Sequence

Why?

மரணம்