Delicious Digg Facebook Favorites More Stumbleupon Twitter

Monday 27 August 2012

ladder if-else condition


                        Ladder if-else Condition

               It is used for comparision between the variables,
               and sub variables.

               syntax:-

                             if(condition)
                            {
                             if(condition)
                             {
                              statements;
                             }
                             else if(condition)
                             {
                             statements;
                             }
                            else if(condition)
                            {
                            statements;
                             }
                            else
                            {
                            statements;
                            }
                            }
                            else
                            {
                            statement;
                             }

            Example:-
                            #include<stdio.h>
                            main()
                           {
                                  int a;
                                  clrscr();
                                  printf("enter a value:");
                                  scanf("%d",&a);
                                  if(a>=35)

                                  {
                                     printf("pass");
                                     if((a >=35)&(a<=50))
                                     printf("c grade");
                                     else if((a>=50)&(a<=75))
                                     printf("b grade");
                                     else
                                     printf("a grade");

                                  }
                                  else

                                     printf("fail");
                                  getch();
                            }





                                             output:-



                         

        

0 comments:

Post a Comment