Thursday, 20 October 2011

page 89 example 3

0 comments
#include<stdio.h>
#include<conio.h>
int x;
main()
{
      x=1;
      while (x<=10)
      {
            printf("%d\n",x);
            x++;
            }
            getch();
            }

Wednesday, 19 October 2011

page 94 #9

0 comments
  #include<stdio.h>
  #include<conio.h>
     #define PONG printf
     #define LORO scanf
    
     int x, y;
     int main()
     {
         for (x = 1; x<10;x++)
         {
             for(y=1;y<x;y++)
             PONG("*");
             PONG("\n",x);
             }
             getch();
             return 0;
             }
      

Example Ni sir!!/* Program to reverse the digits of a number */

0 comments
#include<stdio.h>

#include<conio.h>

int main()

{ int num, rightdigit;

printf("Enter a number \n");


scanf("%d", &num);


while (num != 0)

{

rightdigit = num % 10;

printf("%d", rightdigit);

num = num / 10;

} printf("\n");

getch();

return 0;

}

Tuesday, 18 October 2011

page 83 #9

0 comments

     #include<stdio.h>
     #include<conio.h>
     #define PONG printf
     #define LORO scanf


     int main()
     {
         int temp;
 
         PONG("Enter temperature: ");
         LORO("%d",&temp);
 
              if ( temp < 20 )
                  {
                  PONG("IT'S COLD!");
                  }
             else
             if ( temp > 30 )
                 {
                 PONG("IT'S HOT!");
                 }
            else
                {
                PONG("COOL CLIMATE!");
                }
       getch ();
       return 0;
    }  

page 83

0 comments

     #include<stdio.h>
     #include<conio.h>
     #define PONG printf
     #define LORO scanf

     int main()
     {
         int MG, MB, FE;
         float FG;
         char SN;
 
         PONG("Enter student's name:\n ");
         LORO("%s",&SN);
         PONG("Enter midterm grade:\n ");
         LORO("%d",&MG);
         PONG("Enter minor B:\n ");
         LORO("%d",&MB);
         PONG("Enter final exam:\n ");
         LORO("%d",&FE);
 
         FG = ( MG * .30 ) + ( MB * .10 ) + ( FE * .60 );
         PONG("Your final grade is %.2f or equivalent to ",FG);
 
              if( FG >= 98 && FG <= 100)
                  {
                  PONG("4.00");
                  }
              else
              if( FG >= 95 && FG <= 97)
                  {
                  PONG("3.75");
                  }
              else
              if( FG >= 92 && FG <= 94)
                  {
                  PONG("3.50");
                  }
              else
              if( FG >= 89 && FG <= 91)
                  {
                  PONG("3.25");
                  }
              else
              if( FG >= 86 && FG <= 88)
                  {
                  PONG("3.00");
                  }
              else
              if( FG >= 83 && FG <= 85)
                  {
                  PONG("2.75");
                  }
              else
              if( FG >= 80 && FG <= 82)
                  {
                  PONG("2.50");
                  }
              else
              if( FG >= 77 && FG <= 79)
                  {
                  PONG("2.25");
                  }
              else
              if( FG >= 74 && FG <= 76)
                  {
                  PONG("2.00");
                  }
              else
              if( FG >= 71 && FG <= 73)
                  {
                  PONG("1.75");
                  }
              else
              if( FG >= 68 && FG <= 70)
                  {
                  PONG("1.50");
                  }
              else
              if( FG >= 64 && FG <= 67)
                  {
                  PONG("1.25");
                  }
              else
              if( FG >= 60 && FG <= 63)
                  {
                  PONG("1.00");
                  }
              else
                  {
                  PONG("0.00");
                  }
         getch ();
         return 0;
      }

example page 93 # 4

0 comments
#include<stdio.h>
#include<conio.h>
#define s scanf
#define p printf

int main()
{
          int x, y , z, t, a;
         
          x= 1; y= 2; z= 3;
          for (a= 1; a <4; a++)
          {
              z=z+x;
              x=y+z;
              t=z;
              z=y;
              y=x;
              x=t;
              p("%d%d%d\n",x,y,z);
              }
              getch();
              return 0;
              }

example page 93 # 3

0 comments
#include<stdio.h>
#include<conio.h>
#define s scanf
#define p printf

int main()
{
    int x, y;
   
    for(x=2; x <=4; x++);
             for (y = 5; y>= 3; y--);
             p("%d\n",x+y);
             getch();
             return 0;
             }