Thursday, August 28, 2014

BCA LECTURE-4 C PROGRAMMING 2014

ladder if
if(condition)
{
//PROCESSING STATEMENTS
}
else if(condition)
{
//PROCESSING STATEMENTS
}
else if(condition)
{
//PROCESSING STATEMENTS
}
else
{
//PROCESSING STATEMENTS
}

s1, s2, s3, s4, s5
Per                      Grade
>=80                   A+
>=60                   A
>=45                   B
<45                      C      





Attendance (%)                 Remarks
>=80                                      Excellent
>=60                                      very good
>=45                                      good
<45                                         average
























Nested if: - if within another if

if(condition)  //outer if
{
          if (condition) //inner if
          {

          }
          else
          {

          }
}

else if(condition)
{

}
else
{

}

Take three numbers & determine which number is greater
using nested if
Using logical operator

Take three numbers & determine which number is smaller
15 6 2
a, b, càinput
if(a>b)
{
          if(a>c)
        {
          a is greater
        }
          else
          {
           c is greater
          }
}
else if(b>c)
{
b is greater
}
else
{
c is greater
}









Logical Operator
&&   AND          || OR                  !        NOT



&& AND
t        t                 t
t        f                 f
f        t                 f
f        f                 f
e.g
a=5,b=6
a>b && a<b
f                  t       } f    
a<b && b<a
t                  f        } f

|| OR
t        t        t
t        f        t
f        t         t
f        f        f



e.g
a=8, b=7
a>b || a<b
t                  f  } t 
a<b || b<a
f                  t  } t
a==b && b>a
f                  f  } f



!        NOT
t                  f
f                  t

e.g
a=5, b=6
!(a>b || a<b)
f                 t  }f  

!(a>b && a<b)
 f                  t      }t


a, b, c} input
if (a>b && a>c)
{
a is greater
}
else if(b>a && b>c)
{
b is greater
}
else if(c>a && c>b)
{
c is greater
}


No comments:

Post a Comment

JAC Board Computer || IIT 2025 || Introductory Information Technology || Class 10 || Practical Examination 2025

Marks Division HOE 30 Marks IT Application Report File 20 Marks Viva - Voce 10 Marks 1) Write an HTML code to generate a web p...