Delicious Digg Facebook Favorites More Stumbleupon Twitter

Monday 27 August 2012

nested if-else condition


                      Nested if-else Condition

                It is used for comparision between more than 
                two  variables.

                syntax:- 
    
                             if(condition)
                             {
                                  statements;
                              }
                              else if(condition)
                              {
                                  statements;
                               }
                               else if(condition)
                               {
                                  statements;
                                }
                                else
                                {
                                   statements;
                                 }

                  Example:-  
                                    #include<stdio.h>
                                    main()
                                   {
                                      int a,b,c,d;
                                      clrscr();
                                      printf("enter a,b,c,d values:");
                                      scanf("%d%d%d%d",&a,&b,&c,&d);
                                      if((a>b)&(a>c)&(a>d))
                                      printf("a is big");
                                      else if((b>a)&(b>c)&(b>d))
                                      printf("b is big");
                                      else if((c>a)&(c>b)&(c>d))
                                      printf("c is big");
                                      else
                                      printf("d is big");
                                   getch();
                                   }





                                      
                 output:-

                     

                          

0 comments:

Post a Comment