Biyernes, Oktubre 7, 2011

Lesson namo saturday(Oct. 8, 2011)

*Review sa DEVC++ lessons...

-Conditional Statements:
◘◘Sample #1:
•Create a program that will display the largest inputted value!

   #include<stdio.h>
   #include<conio.h>

   int main()
   {
          int x,y;
      
          printf("Enter value for x :");
          scanf("%d",&x);
          printf("Enter value for y :");
          scanf("%d",&y);
      
          if ( x > y )
          {
                  printf("X is large number - %d\n",x);
          }
          else
          {
                 printf("Y is large number - %d\n",y);
          }
          getch();
          return 0;
}

◘◘Sample #2 :
 •Write a program that will display "Pretty Young" if age is lesser than 18, and will display "You Old" if age 
    is  greater than 18.

   #include<stdio.h>
   #include<conio.h>

   int main()
   {
          int age;
       
          printf("Enter age:");
          scanf("%d",&age);
      
          if ( age <= 18 )
         {
               printf("Pretty Young!");
         }
         else      
        {
               printf("Your Old!");
       }
       getch();
       return 0;
}

Walang komento:

Mag-post ng isang Komento