Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a C program using if/else statement: Filename Input Output: homework_05a_

ID: 3797131 • Letter: C

Question

Create a C program using if/else statement: Filename Input Output: homework_05a_lastnamefirstnameinitial. c: two variables A and B in double. Filename Input Output: print the biggest number among A and B, or if they are the same value, print the message to inform the user. Filename Input Output: homework_05b_lastnamefirstnameinitial.c: homework_05c_lastnamefirstnameinitial.c: a grade in number in double between 0 and 100.: one variable in integer: determine if the input is even or odd: print the grade in letter with this criteria: grade >=90 A; 80

Explanation / Answer

2) even or odd

     # include < stdio.h >

    # include < conio.h >

    void main ( )

     {

           int n ;

           clrscr ( ) ;

           printf ( " Enter a number : " ) ;

           scanf ( " %d " , & n );

           if ( n % 2 == 0 )

                printf ( " % d is even " , n ) ;

             else

                printf ( " %d is odd " , n ) ;

               return 0 ;

}

   o/p -

    enter a number : 6

      6 is even

1) biggest number

   # include < stdio.h >

    int main ( )

    {

        float a , b ;

        clrscr ( ) ;

        printf ( " Enter two numbers : " ) ;

        scanf ( " % f % f " , &a ,&b ) ;

        if ( a > = b )

          {

              if ( b > = a )

                     printf ( " largest number = %f " , &a ) ;

       else

              printf ( " largest number = %f " , &b ) ;

         }

      else

        {

            if ( a == b )

               printf ( " same number " ) ;

           else

                return 0 ;

   }

}

o/p - enter two numbers : 25

30

largest number = 30.0000

enter two numbers : 25

25

same number     

3) student grading

    # include < stdio.h >

    # include < conio.h >

   void main ( )

   {

      int S1 , S2 , S3 , S4 ,S5 , S6 , per ;

      clrscr ( ) ;

      printf ( " Enter the marks " ) ;

      scanf( " %d %d %d %d %d %d " , &S1 , &S2 , &S3 , &S4 ,&S5 , &S6 );

       per = ( S1 + S2 ,+S3 + S4 +S5 + S6 ) / 6 ;

       if ( per > = 90 )

         {

             printf ( " A grade " ) ;

         }

      else if ( per < 90 && per > = 80 )

         {

              printf ( " B grade " ) ;

         }

     else if ( per < 80 && per > = 70 )

        {

             printf ( " C grade " ) ;

        }

   else if ( per < 70 && per > = 50 )

        {

             printf ( " D grade " ) ;

        }

else if ( per < 50 && per > = 40 )

        {

             printf ( " failed " ) ;

        }

      getch ( ) ;

}

o/p

enter the marks -

92

94

96

97

91

90

result - A grade