Pages

Showing posts with label nested else if statement. Show all posts
Showing posts with label nested else if statement. Show all posts

Monday, 12 September 2016

Nested if Statement in C Programming



nested if Statement

เคจेเคธ्เคŸेเคก if เคธ्เคŸेเคŸเคฎेंเคŸ เคธी เคช्เคฐोเค—्เคฐाเคฎिंเค— เคฎे เค•िเคธी if statement เคฏा if else เคธ्เคŸेเคŸเคฎेंเคŸ เค•े เค…ंเคฆเคฐ เคฆूเคธเคฐे if เคธ्เคŸेเคŸเคฎेंเคŸ เคฏा if else เคธ्เคŸेเคŸเคฎेंเคŸ เค•े เคช्เคฐเคฏोเค— เค•ो เค…เคจुเคฎเคคि เคช्เคฐเคฆाเคจ เค•เคฐเคคा เคนैं। เคœैเคธे

if (condition)
   {
      If (condition)
        {
        Statement 1 ;
        Statement 2 ;
         }
}

เคœैเคธा เค•ी เค†เคช เคŠเคชเคฐ เคฆिเคฏे เคนुเคฏे เคธिंเคŸैเค•्เคธ เค•ो เคฆेเค– เคธเค•เคคे เคนैं, เค•ी เคเค• if เคธ्เคŸेเคŸเคฎेंเคŸ เค•े เค…ंเคฆเคฐ เคฆूเคธเคฐा if เคธ्เคŸेเคŸเคฎेंเคŸ เค•ा เค‰เคชเคฏोเค— เค•िเคฏा เค—เคฏा เคนैं। เค‡เคธ เคช्เคฐเค•ाเคฐ เค•े if เคธ्เคŸेเคŸเคฎेंเคŸ เค•ो เคจेเคธ्เคŸेเคก if เคธ्เคŸेเคŸเคฎेंเคŸ เค•เคนเคคे เคนैं।

เค‡เคธเค•ा เค‰เคชเคฏोเค— เคœเคฌ เค•िเคฏा เคœाเคคा เคนैं เคœเคฌ เค†เคช เคเค• เคถเคฐ्เคค (condition) เค•े เคธเคนी เคนोเคจे เค•े เคฌाเคฆ เคฆूเคธเคฐे เค•ंเคกीเคถเคจ เค•ो เคœाँเคšเคจा เคšाเคนเคคे เคนैं।

* Find largest among 3 variables using nested if */

#include
int main()
{
    int a,b,c;
    printf("Enter 3 numbers: \n");
    scanf("%d %d %d",&a,&b,&c);
    if(a>=b)
    {
        if(a>=c)
            printf("%d is largest",a);
        else
            printf("%d is largest",c);
    }
    else
{ if(b>=c)
        printf("%d is largest",b);
    else
        printf("%d is largest",c);
}
    return 0;
}

เคฏเคน เคเค• เคช्เคฐोเค—्เคฐाเคฎ เคนैं เคœिเคธเคฎे 3 เคตेเคฐिเคเคฌเคฒ เคฎे เคธเคฌเคธे เคฌเฅœे เคตेเคฐिเคฏเคฌเคฒ เค•ो เคชเคคा เค•เคฐเคจा เคนै, เค‡เคธเคฎे เค†เคช เคฆेเค– เคธเค•เคคे เคนैं เค•ी nested if เค•ा เค‡เคธ्เคคेเคฎाเคฒ เค•िเคฏा เค—เคฏा เคนैं।

เค‡เคธ เคช्เคฐोเค—्เคฐाเคฎ เคฎे เคธเคฌเคธे เคชเคนเคฒे เคตाเคฒे if เคฎे a>b เค•ो เคœांเคšा เคœा เคฐเคนा เคนैं, เค…เค—เคฐ เคถเคฐ्เคค เคธเคนी เคนुเคˆ เคคो a>c เค•ो เคœांเคšा เคœाเคเค—ा। เค…เค—เคฐ เคชเคนเคฒी เคถเคฐ्เคค เค—เคฒเคค เคนो เคœाเคคी เคคो เคฆूเคธเคฐी เคถเคฐ्เคค เค•ो เคจเคนीं เคœांเคšा เคœाเคเค—ा, เคฌเคฒ्เค•ि เคช्เคฐोเค—्เคฐाเคฎ เค•ा เค•ंเคŸ्เคฐोเคฒ เคชเคนเคฒे if เค•े else เค•ो เคชाเคธ เคนो เคœाเคเค—ा। เค…เคฌ เค†เคช เคฆेเค–ेंเค—े เค•ी เค‰เคธ else เค•े เค…ंเคฆเคฐ เคญी เคเค• if else stetment เคช्เคฐเคฏोเค— เค•िเคฏा เค—เคฏा เคนैं। เคœिเคธเคฎे b >= c เคœांเคšा เคœा เคฐเคนा เคนैं। เคคो เค†เคช เค‡เคธ เคช्เคฐोเค—्เคฐाเคฎ เคฎे เคจेเคธ्เคŸेเคก if stetment เค•ा เคช्เคฐเคฏोเค— เคฆेเค– เคธเคฎเค เค—เค เคนोंเค—े เค•ी เคจेเคธ्เคŸेเคก if statement เคเค• if เคฏा else เคฌॉเคกी เค•े เค…ंเคฆเคฐ เค‰เคชเคฏोเค— เคฆूเคธเคฐे if เคฏा if else เคธ्เคŸेเคŸเคฎेंเคŸ เค•े เคช्เคฐเคฏोเค— เค•ो เค•เคนเคคे เคนैं।

เค…เคฌ เคจेเคธ्เคŸेเคก if เค•ो เคธเคฎเคเคจे เค•े เคฒिเค เคจीเคšे เคเค• เคšिเคค्เคฐ เคฆिเคฏा เคœा เคฐเคนा เคนैं เค‰เคธे เคฆेเค– เคจेเคธ्เคŸेเคก if stetment เค•ो เคธเคฎเคเคจे เค•ा เคช्เคฐเคฏाเคธ เค•เคฐे।


Popular Posts