SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler offline
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
        FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
        BTI10202 COMPUTER PROGRAMMING

                                    TEST 1-MONDAY

 Write a program to calculate mass of the liquid in a tank. Allow the user to input the
 volume either in cm or meter, and prompt the user to recalculate if desire.

 Note that:

 Oil density (ρ)= 850 kg/m3

 Mass=ρV




The output should be similar to:
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING


#include<stdio.h>

#include<conio.h>

#include<math.h>

main(){

   float oildensity, tankvolume,mass=0;

   char oilunit,again;

   printf("This program calculate the mass of oil in a tank");

   start:

   printf("nnEnter oil density: ");scanf("%f",&oildensity);

   printf("Enter tank volume: ");scanf("%f",&tankvolume);

   printf("nEnter volume unit(m=meter, c=centimeter): ");scanf("%s",&oilunit);

   recalculate:

   switch (oilunit){

          case 'c':

          mass= oildensity*((pow(tankvolume,3))/pow(100,3)); break;

          case 'm':

          mass= oildensity*(pow(tankvolume,3)); break;

          default:

          printf("You have entered a wrong type of unit");

          printf("nnEnter oil density unit(g for gram/k for kg): ");scanf("%s",&oilunit);

          goto recalculate; }

    printf("nntThe Mass of oil is %.4fkg",mass);

    printf("nnDo you want to re-calculate: ");scanf("%s",&again);

    if(again=='y' || again=='Y')

    goto      start;

   getch();

   }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING



#include<stdio.h>

#include<conio.h>

#include<math.h>

main(){

   float oildensity, tankvolume,mass=0;

   char oilunit,again;

   printf("This program calculate the mass of oil in a tank");

   start:

   printf("nnEnter oil density: ");scanf("%f",&oildensity);

   printf("Enter tank volume: ");scanf("%f",&tankvolume);

   printf("nEnter volume unit(m=meter, c=centimeter): ");scanf("%s",&oilunit);

   recalculate:

          if (oilunit== 'c'){

          mass= oildensity*((pow(tankvolume,3))/pow(100,3)); }

        else if (oilunit== 'm'){

       mass= oildensity*(pow(tankvolume,3));}

       else{

          printf("You have entered a wrong type of unit");

          printf("nnEnter oil density unit(g for gram/k for kg): ");scanf("%s",&oilunit);

          goto recalculate; }

    printf("nntThe Mass of oil is %.4fkg",mass);

    printf("nnDo you want to re-calculate(enter y for yes): ");scanf("%s",&again);

    if(again=='y' || again=='Y')

    goto       start;

   getch();

   }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING



#include<stdio.h>

#include<conio.h>

main(){

   float oildensity, tankvolume,mass=0;

   char oilunit,again;

   printf("This program calculate the mass of oil in a tank");

   start:

   printf("nnEnter oil density: ");scanf("%f",&oildensity);

   printf("Enter tank volume: ");scanf("%f",&tankvolume);

   printf("nEnter volume unit(m=meter, c=centimeter): ");scanf("%s",&oilunit);

   recalculate:

   switch (oilunit){

          case 'c':

          mass= oildensity*(tankvolume/100); break;

          case 'm':

          mass= oildensity*tankvolume; break;

          default:

          printf("You have entered a wrong type of unit");

          printf("nnEnter oil density unit(g for gram/k for kg): ");scanf("%s",&oilunit);

          goto recalculate;

          }

    printf("nntThe Mass of oil is %.4fkg",mass);

    printf("nnDo you want to re-calculate: ");scanf("%s",&again);

    if(again=='y' || again=='Y')

    goto      start;

   getch();

   }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING




#include<stdio.h>

#include<conio.h>

main(){

   float oildensity, tankvolume,mass=0;

   char oilunit,again;

   printf("This program calculate the mass of oil in a tank");

   start:

   printf("nnEnter oil density: ");scanf("%f",&oildensity);

   printf("Enter tank volume: ");scanf("%f",&tankvolume);

   printf("nEnter volume unit(m=meter, c=centimeter): ");scanf("%s",&oilunit);

   recalculate:

          if (oilunit== 'c'){

          mass= oildensity*(tankvolume/100); }

        else if (oilunit== 'm'){

          mass= oildensity*tankvolume;}

       else{

          printf("You have entered a wrong type of unit");

          printf("nnEnter oil density unit(g for gram/k for kg): ");scanf("%s",&oilunit);

          goto recalculate;

          }

    printf("nntThe Mass of oil is %.4fkg",mass);

    printf("nnDo you want to re-calculate(enter y for yes): ");scanf("%s",&again);

    if(again=='y' || again=='Y')

    goto       start;

   getch();

   }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

                                          TEST 1-TUESDAY

                                    Base on the table develop a simple program on how long should a
                                    man/woman should exercise to burn calories off either by jogging or
                                    bicycling. The user must be able to keep calculating until the key end
                                    otherwise.

                                    Example: A 65kg woman needs to burn of 800 calories by jogging, how
                                    long does she need to jog in order to burn of all of the calories.


                                                                                ������������������������������������������������ ������������������������������������������������              540
                                     Energy output: ������������������������ℎ������ ������                                                  Δ 64 x
                                                                                           68������������                              68

                                                  ������������������������������ ������������������������������������������������                                            800
                                     Duration:                                                                      Δ
                                                 ������������������������������������ ������������������������������������                                              516.17




The output should be similar to :
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

#include<stdio.h>

#include<conio.h>

main(){

  float calorin,weight,totalhour=0;

  int type;

  char again;

  printf("ttt444Exercise Calculator444nn");

  start:

  printf("nEnter calories intake: ");scanf("%f",&calorin);

  printf("Enter your weight: ");scanf("%f",&weight);

  choose:

   printf("nPlease choose type of exercise n1. Joggingn2. BicyclingnPlease enter type:
");scanf("%d",&type);

  switch(type){

             case 1:

                  totalhour=calorin/(weight*(540/68));

             printf("ntIn order to burn %.f of calories you need to jog for
%.1fhr",calorin,totalhour);break;

             case 2:

                  totalhour=calorin/(weight*(639/68));

             printf("ntIn order to burn %.f of calories you need to cycle for
%.1fhr",calorin,totalhour);break;

             default:

                  goto choose;break;

             }

   if(again=='y' || again=='Y')

      goto       start;

  getch();

  }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING




#include<stdio.h>

#include<conio.h>

main(){

  float calorin,weight,totalhour=0;

  int type;

  char again;

  printf("ttt444Exercise Calculator444nn");

  start:

  printf("nEnter calories intake: ");scanf("%f",&calorin);

  printf("Enter your weight: ");scanf("%f",&weight);

  choose:

   printf("nPlease choose type of exercise n1. Joggingn2. BicyclingnPlease enter type:
");scanf("%d",&type);

if (type==1){

totalhour=calorin/(weight*(540/68));

printf("ntIn order to burn %.f of calories you need to jog for %.1fhr",calorin,totalhour); }

else if (type==2){

totalhour=calorin/(weight*(639/68));

printf("ntIn order to burn %.f of calories you need to cycle for %.1fhr",calorin,totalhour); }

else { goto choose;}

   if(again=='y' || again=='Y')

      goto    start;

  getch();

  }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

                                          TEST 1-TUESDAY

                                    Base on the table develop a simple program on how long should a
                                    man/woman should exercise to burn calories off either by jogging or
                                    playing tennis. The user must be able to keep calculating until the key
                                    end otherwise.

                                    Example: A 65kg woman needs to burn of 800 calories by jogging, how
                                    long does she need to jog in order to burn of all of the calories.


                                                                                ������������������������������������������������ ������������������������������������������������              540
                                     Energy output: ������������������������ℎ������ ������                                                  Δ 64 x
                                                                                           68������������                              68

                                                  ������������������������������ ������������������������������������������������                                            800
                                     Duration:                                                                      Δ
                                                 ������������������������������������ ������������������������������������                                              508.23




The output should be similar to :
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING


#include<stdio.h>

#include<conio.h>

main(){

  float calorin,weight,totalhour=0;

  int type;

  char again;

  printf("ttt444Exercise Calculator444nn");

  start:

  printf("nEnter calories intake: ");scanf("%f",&calorin);

  printf("Enter your weight: ");scanf("%f",&weight);

  choose:

   printf("nPlease choose type of exercise n1. Joggingn2. TennisnPlease enter type:
");scanf("%d",&type);

  switch(type){

case 1:

totalhour=calorin/(weight*(540/68));

printf("ntIn order to burn %.f of calories you need to jog for %.1fhr",calorin,totalhour);break;

case 2:

totalhour=calorin/(weight*(480/68));

 printf("ntIn order to burn %.f of calories you need to play intense tennis for %.1fhr",
calorin,totalhour); break;

default:

goto choose; break;        }

      printf("nnDo you want to re-calculate(enter y for yes): ");scanf("%s",&again);

      if(again=='y' || again=='Y')

      goto    start;

  getch();

  }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING



#include<stdio.h>

#include<conio.h>

main(){

  float calorin,weight,totalhour=0;

  int type;

  char again;

  printf("ttt444Exercise Calculator444nn");

  start:

  printf("nEnter calories intake: ");scanf("%f",&calorin);

  printf("Enter your weight: ");scanf("%f",&weight);

  choose:

   printf("nPlease choose type of exercise n1. Joggingn2. TennisnPlease enter type:
");scanf("%d",&type);

if(type==1){

totalhour=calorin/(weight*(540/68));

printf("ntIn order to burn %.f of calories you need to jog for %.1fhr",calorin,totalhour);}

else if(type==2){

totalhour=calorin/(weight*(480/68));

printf("ntIn order to burn %.f of calories you need to play intense tennis for
%.1fhr",calorin,totalhour); }

else{

goto choose;       }

      printf("nnDo you want to re-calculate(enter y for yes): ");scanf("%s",&again);

      if(again=='y' || again=='Y')

      goto     start;

  getch();

  }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

                                         TEST 1-TUESDAY

                                    Base on the table develop a simple program on how long should a
                                    man/woman should exercise to burn calories off either by fast swimming
                                    or bicycling. The user must be able to keep calculating until the key end
                                    otherwise.

                                    Example: A 65kg woman needs to burn of 800 calories by jogging, how
                                    long does she need to jog in order to burn of all of the calories.


                                                                                ������������������������������������������������ ������������������������������������������������              540
                                     Energy output: ������������������������ℎ������ ������                                                  Δ 64 x
                                                                                           68������������                              68

                                                  ������������������������������ ������������������������������������������������                                            800
                                     Duration:                                                                      Δ
                                                 ������������������������������������ ������������������������������������                                              508.23




The output should be similar to :
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

#include<stdio.h>

#include<conio.h>

main(){

  float calorin,weight,totalhour=0;

  int type;

  char again;

  printf("ttt444Exercise Calculator444nn");

  start:

  printf("nEnter calories intake: ");scanf("%f",&calorin);

  printf("Enter your weight: ");scanf("%f",&weight);

  choose:

   printf("nPlease choose type of exercise n1. Fast Swimmingn2. BicyclingnPlease enter type:
");scanf("%d",&type);

  switch(type){

           case 1:

               totalhour=calorin/(weight*(860/68));

             printf("ntIn order to burn %.f of calories you need to fast swimming for
%.1fhr",calorin,totalhour);break;



           case 2:



               totalhour=calorin/(weight*(639/68));

             printf("ntIn order to burn %.f of calories you need to cycle for
%.1fhr",calorin,totalhour);

               break;



                        default:

               goto choose;break;



           }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING




#include<stdio.h>

#include<conio.h>

main(){

   float calorin,weight,totalhour=0;

   int type;

  char again;

   printf("ttt444Exercise Calculator444nn");

  start:

   printf("nEnter calories intake: ");scanf("%f",&calorin);

   printf("Enter your weight: ");scanf("%f",&weight);

  choose:

   printf("nPlease choose type of exercise n1. Fast Swimmingn2. BicyclingnPlease enter type:
");scanf("%d",&type);

if(type==1){

totalhour=calorin/(weight*(860/68));

printf("ntIn order to burn %.f of calories you need to fast swimming for %.1fhr",
calorin,totalhour);}

else if (type==2){

totalhour=calorin/(weight*(639/68));

printf("ntIn order to burn %.f of calories you need to cycle for %.1fhr",calorin,totalhour); }

else{

                goto choose; }

   if(again=='y' || again=='Y')

      goto     start;

   getch();

  }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

                                         TEST 1-WEDNESDAY



        Develop a simple program to calculate
        radius of a circle. The user need to
        choose whether to input area or
        circumference of the circle.

        Note that:

        area= πxrad2

        and circumference = 2xπxrad




The output should be similar to:




The user must be able to keep calculating until the key end otherwise.
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

#include<stdio.h>

#include<conio.h>

#include<math.h>

#define PI 3.1416

main(){

   char type,again;

   float radius,circumference,area;

   printf("t444This program calculate radius of a circle444");

   start:

   printf("nna:areanc:circumferencennEnter the information that you have:");

   scanf("%s",&type);

   cal:

   switch(type){

             case 'a':

                printf("nEnter area of a circle:");scanf("%f",&area);

                radius = sqrt(area/PI);

                printf("nThe area of a circle is %.2f while the radius is %.4f",area,radius); break;

             case 'c':

                printf("nEnter circumference of a circle:");scanf("%f",&circumference);

                radius= circumference/(PI*2);

               printf("nThe circumference of a circle is %.2f while the radius is
          %.4f",circumference,radius);break;

             default:

                  printf("na:areanc:circumferencennPlease re-enter selection:");

                  scanf("%s",&type); goto cal; }

             if(again=='y' || again=='Y') { goto   start;}

   getch();

   }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
           FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
           BTI10202 COMPUTER PROGRAMMING

#include<stdio.h>

#include<conio.h>

#include<math.h>

#define PI 3.1416

main(){

    char type,again;

    float radius,circumference,area;

    printf("t444This program calculate radius of a circle444");

   start:

    printf("nna:areanc:circumferencennEnter the information that you have:");

    scanf("%s",&type);

    cal:

    if (type=='a'){

                 printf("nEnter area of a circle:");scanf("%f",&area);

                 radius = sqrt(area/PI);

                 printf("nThe area of a circle is %.2f while the radius is %.4f",area,radius);}

    else if(type== 'c'){

                  printf("nEnter circumference of a circle:");scanf("%f",&circumference);

                 radius=circumference/(PI*2);

printf("nThe circumference of a circle is %.2f while the radius is %.4f",circumference,radius);}

    else{

                   printf("na:areanc:circumferencennPlease re-enter selection:");

                   scanf("%s",&type); goto cal;}

             if(again=='y' || again=='Y')

    goto       start;

    getch();




    }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

                                         TEST 1-WEDNESDAY




                                                            Develop a simple program to calculate
                                                            either an area or perimeters of a semi
                                                            circle. The program must prompt the
                                                            user to input radius.

                                                            Note that:

                                                            area= πxrad2

                                                            and circumference = 2xπxrad



The output should be similar to :




                                                                                   20.7075




The user must be able to keep calculating until the key end otherwise.
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
           FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
           BTI10202 COMPUTER PROGRAMMING

#include<stdio.h>

#include<conio.h>

#define PI 3.1415

main(){

    char type,again;

    float radius,circumference,area,perimeters;

    printf("t444SEMI-CIRCLE CALCULATOR444");

    start:

    printf("na:areanp:perimetersnnEnter selection:");

    scanf("%s",&type);

    printf("nEnter radius of the semi-circle:");

    scanf("%f",&radius);

    cal:

    switch(type){

             case 'a':

              area= 0.5*(PI*pow(radius,2));

              printf("nThe area of a semi-circle for %.2f radius is %.4f",radius,area); break;

             case 'p':

              circumference= 2*PI*radius;

              perimeters= (2 *radius)+ (circumference/2);

printf("nThe perimeters of a semi-circle for %.2f of radius is %.4f",radius,perimeters);break;

             default:

                  printf("wrong selection");

                  printf("na:areanp:PerimetersnnPlease re-enter selection:");

                  scanf("%s",&type); goto cal; }

                 if(again=='y' || again=='Y')

    goto     start;

    getch(); }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
           FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
           BTI10202 COMPUTER PROGRAMMING

#include<stdio.h>

#include<conio.h>

#define PI 3.1415

main(){

    char type,again;

    float radius,circumference,area,perimeters;

    printf("t444SEMI-CIRCLE CALCULATOR444");

    start:

    printf("na:areanp:perimetersnnEnter selection:");

    scanf("%s",&type);

    printf("nEnter radius of the semi-circle:");

    scanf("%f",&radius);

    cal:

   if(type=='a'){

                 area= 0.5*(PI*pow(radius,2));

                 printf("nThe area of a semi-circle for %.2f radius is %.4f",radius,area);}

   else if(type=='p'){

                 circumference= 2*PI*radius;

                 perimeters= (2 *radius)+ (circumference/2);

printf("nThe perimeters of a semi-circle for %.2f of radius is %.4f",radius,perimeters);}

  else{            printf("wrong selection");

                   printf("na:areanp:PerimetersnnPlease re-enter selection:");

                   scanf("%s",&type); goto cal;

             }

    if(again=='y' || again=='Y')

    goto       start;

    getch();

    }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
        FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
        BTI10202 COMPUTER PROGRAMMING

                                   TEST 1-THURSDAY



 Write a program to prove the theory of prefix and postfix in C Program slybuss. Allow the
 user to keep testing until ‘n’ is keyed in by the user

 Note that:

 Postfix : a++,a—

 Prefix :++a,--a




The output should be similar to:
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING


#include<stdio.h>

#include<conio.h>

main(){

   int a,prepost;

   char b;

   printf("tThis program is use to proof theory of postfix and prefix");

   sekalilagi:

   printf("nnEnter value a: "); scanf("%d",&a);

   choose:

printf("nPlease choosen1. postfixn2. PrefixnPlease enter your choice: ");
scanf("%d",&prepost);

   switch (prepost){

        case 1:

            printf("npostfix/a++ for a is %d at the end a =%d", a++,a);

            printf("nand a after ; is %d",a);

            printf("nnpostfix/a-- for a is %d at the end a =%d", a--,a);

            printf("nand a after ; is %d",a); break;

        case 2:

            printf("nprefix/++a for a = %d at the end a =%d", ++a,a);

            printf("nand a after ; is %d",a);

            printf("nnprefix/--a for a = %d at the end a =%d", --a,a);

            printf("nand a after ; is %d",a); break;

        default: goto choose;         }

       printf("nnEnter n to stop re-trying: "); scanf("%s",&b);

   if (b!='n'){ goto sekalilagi;}

   getch();

   }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING


#include<stdio.h>

#include<conio.h>

main(){

   int a,prepost;

   char b;

   printf("tThis program is use to proof theory of postfix and prefix");

   sekalilagi:

   printf("nnEnter value a: "); scanf("%d",&a);

   choose:

    printf("nPlease choosen1. postfixn2. PrefixnPlease enter your choice: ");
scanf("%d",&prepost);



if (prepost==1){

            printf("npostfix/a++ for a is %d at the end a =%d", a++,a);

            printf("nand a after ; is %d",a);

            printf("nnpostfix/a-- for a is %d at the end a =%d", a--,a);

            printf("nand a after ; is %d",a); }

else if (prepost==2){

            printf("nprefix/++a for a = %d at the end a =%d", ++a,a);

            printf("nand a after ; is %d",a);

            printf("nnprefix/--a for a = %d at the end a =%d", --a,a);

            printf("nand a after ; is %d",a);}

 else { goto choose;}

       printf("nnEnter n to stop re-trying: "); scanf("%s",&b);

   if (b!='n'){ goto sekalilagi;}

   getch();

   }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
        FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
        BTI10202 COMPUTER PROGRAMMING

                                    TEST 1-FRIDAY


 Write a program to segregat number of students according to :

  GRADE E: 0 <= mark <=49

 GRADE D: 50 <=mark <=59

 GRADE C: 60 <= mark <=69

 GRADE B: 70 <= mark <=79

 GRADE A: 80 <= mark <=100




The output should be similar to:
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING




#include<stdio.h>

#include<conio.h>

int main(){

  int noofstudent=0,mark=0, gradeA=0,gradeB=0,gradeC=0,gradeD=0,gradeE=0;

  int i=1;

  printf("44The Program segregrate the number of students according to grade44 ");

  printf("nnEnter Number of student: "); scanf ("%d",&noofstudent);

loop:

        printf("%d student mark: ",i); scanf ("%d",&mark);

             if (mark>=0 && mark <=49)

             { gradeE++;       }

             else if (mark>=50 && mark <=59)

             { gradeD++;           }

             else if (mark>=60 && mark <=69)

             { gradeC++;       }

             else if (mark>=70 && mark <=79)

             { gradeB++;           }

             else if (mark>=80 && mark <=100)

             { gradeA++;           }



i++;

if (i<noofstudent)

goto loop;
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
       FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
       BTI10202 COMPUTER PROGRAMMING




printf("n______________________________________________n ");

printf("nThere is %d students receive grade A ",gradeA);

printf("nThere is %d students receive grade B ",gradeB);

printf("nThere is %d students receive grade C ",gradeC);

printf("nThere is %d students receive grade D ",gradeD);

printf("nThere is %d students receive grade E ",gradeE);



  getch();

  return 0;

  }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

                                             TEST 1-FRIDAY



       Develelope a simple program which
       receive radius of a circle from user and
       allowed user to choose between
       calculating area of a circle or
       circumferense of a circle,:

       Note that:

       area= πxrad2

       and circumference = 2xπxrad



The output should be similar to :




The user must be able to keep calculating until the key end otherwise.
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

#include<stdio.h>

#include<conio.h>

#include<math.h>

#define PI 3.1416

main(){

   char type,b;

   float radius,circumference,area;

   printf("This program calculate Area or Circumference of a circle");

   again:

   printf("na:areanc:circumferencennEnter selection:");scanf("%s",&type);

   printf("nEnter radius of a circle:"); scanf("%f",&radius);

   cal:

   switch(type){

            case 'a':

              area= PI*pow(radius,2);

              printf("nThe area of a circle for %.2fcm radius is %.4f",radius,area); break;

            case 'c':

              circumference= 2*PI*radius;

printf("nThe circumference of a circle for %.2fcm radius is %.4f",radius,circumference);break;

            default:

                 printf("wrong selection");

                 printf("na:areanc:circumferencennPlease re-enter selection:");

                 scanf("%s",&type); goto cal; }

   printf("nnEnter n to stop re-trying: "); scanf("%s",&b);

   if (b!='n'){ goto again;}

   getch();



   }
UNIVERSITI TUN HUSSEIN ONN MALAYSIA
          FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
          BTI10202 COMPUTER PROGRAMMING

#include<stdio.h>

#include<conio.h>

#include<math.h>

#define PI 3.1416

main(){

   char type,b;

   float radius,circumference,area;

   printf("This program calculate Area or Circumference of a circle");

   again:

   printf("na:areanc:circumferencennEnter selection:");

   scanf("%s",&type);

   printf("nEnter radius of a circle:");

   scanf("%f",&radius);

   cal:

   if (type=='a'){

              area= PI*pow(radius,2);

              printf("nThe area of a circle for %.2fcm radius is %.4f",radius,area); }

   else if (type=='c') {

              circumference= 2*PI*radius;

             printf("nThe circumference of a circle for %.2fcm radius is
          %.4f",radius,circumference);}

   else {

                 printf("wrong selection");

                 printf("na:areanc:circumferencennPlease re-enter selection:");

                 scanf("%s",&type); goto cal; }

   printf("nnEnter n to stop re-trying: "); scanf("%s",&b);

   if (b!='n'){ goto again;}

   getch();          }

Mais conteúdo relacionado

Destaque

Cuestions auga gliciddo_lipidos_e_protidos new
Cuestions auga gliciddo_lipidos_e_protidos newCuestions auga gliciddo_lipidos_e_protidos new
Cuestions auga gliciddo_lipidos_e_protidos newjuanapardo
 
MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化Akira Tanimoto
 
โครงงานครั้งที่ 2
โครงงานครั้งที่ 2โครงงานครั้งที่ 2
โครงงานครั้งที่ 2NattAA
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionalish sha
 
The Many Faces Of Maddie
The  Many  Faces Of  MaddieThe  Many  Faces Of  Maddie
The Many Faces Of MaddieAngie Hopkins
 
The krass family 2010
The krass family 2010The krass family 2010
The krass family 2010Mike Krass
 
Advert planning
Advert planningAdvert planning
Advert planningReganROFL
 
Jr Shipping Actueel 15
Jr Shipping Actueel 15Jr Shipping Actueel 15
Jr Shipping Actueel 15windrose1
 
Some of my projects
Some of my projectsSome of my projects
Some of my projectsnsharmaji
 
Master chef 2nd eso 2013
Master chef 2nd eso 2013Master chef 2nd eso 2013
Master chef 2nd eso 2013IES Consaburum
 
K2 atomic structure
K2 atomic structureK2 atomic structure
K2 atomic structureRathiga Sri
 
Media Speak on AdvertisementIndia
Media Speak on AdvertisementIndiaMedia Speak on AdvertisementIndia
Media Speak on AdvertisementIndiaadvertisementindia
 
Presentation1
Presentation1Presentation1
Presentation1scorbi2
 
Videos caminando con caverncolas
Videos caminando con caverncolasVideos caminando con caverncolas
Videos caminando con caverncolasjuanapardo
 
Assessment to programming for reading
Assessment to programming for readingAssessment to programming for reading
Assessment to programming for readingKrystle Levings
 
Building Google Authorship Authority
Building Google Authorship AuthorityBuilding Google Authorship Authority
Building Google Authorship AuthorityMarvin Libron
 
愛知中小企業家同友会IT研究会 7月例会
愛知中小企業家同友会IT研究会 7月例会愛知中小企業家同友会IT研究会 7月例会
愛知中小企業家同友会IT研究会 7月例会新一 佐藤
 

Destaque (20)

Cuestions auga gliciddo_lipidos_e_protidos new
Cuestions auga gliciddo_lipidos_e_protidos newCuestions auga gliciddo_lipidos_e_protidos new
Cuestions auga gliciddo_lipidos_e_protidos new
 
MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化MLP輪読スパース8章 トレースノルム正則化
MLP輪読スパース8章 トレースノルム正則化
 
โครงงานครั้งที่ 2
โครงงานครั้งที่ 2โครงงานครั้งที่ 2
โครงงานครั้งที่ 2
 
Dti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selectionDti2143 chap 4 control structures aka_selection
Dti2143 chap 4 control structures aka_selection
 
The Many Faces Of Maddie
The  Many  Faces Of  MaddieThe  Many  Faces Of  Maddie
The Many Faces Of Maddie
 
The krass family 2010
The krass family 2010The krass family 2010
The krass family 2010
 
Advert planning
Advert planningAdvert planning
Advert planning
 
Damcalifornia
DamcaliforniaDamcalifornia
Damcalifornia
 
Jr Shipping Actueel 15
Jr Shipping Actueel 15Jr Shipping Actueel 15
Jr Shipping Actueel 15
 
What is AriseDM ?
What is AriseDM ?What is AriseDM ?
What is AriseDM ?
 
Some of my projects
Some of my projectsSome of my projects
Some of my projects
 
Master chef 2nd eso 2013
Master chef 2nd eso 2013Master chef 2nd eso 2013
Master chef 2nd eso 2013
 
K2 atomic structure
K2 atomic structureK2 atomic structure
K2 atomic structure
 
الرسم المظوري
الرسم المظوريالرسم المظوري
الرسم المظوري
 
Media Speak on AdvertisementIndia
Media Speak on AdvertisementIndiaMedia Speak on AdvertisementIndia
Media Speak on AdvertisementIndia
 
Presentation1
Presentation1Presentation1
Presentation1
 
Videos caminando con caverncolas
Videos caminando con caverncolasVideos caminando con caverncolas
Videos caminando con caverncolas
 
Assessment to programming for reading
Assessment to programming for readingAssessment to programming for reading
Assessment to programming for reading
 
Building Google Authorship Authority
Building Google Authorship AuthorityBuilding Google Authorship Authority
Building Google Authorship Authority
 
愛知中小企業家同友会IT研究会 7月例会
愛知中小企業家同友会IT研究会 7月例会愛知中小企業家同友会IT研究会 7月例会
愛知中小企業家同友会IT研究会 7月例会
 

Mais de alish sha

T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9alish sha
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)alish sha
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation alish sha
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifahalish sha
 
It 302 computerized accounting (week 1) - sharifah
It 302   computerized accounting (week 1) - sharifahIt 302   computerized accounting (week 1) - sharifah
It 302 computerized accounting (week 1) - sharifahalish sha
 
What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)alish sha
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13alish sha
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13alish sha
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012alish sha
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaboratealish sha
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1alish sha
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12alish sha
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&aalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Final project
Final projectFinal project
Final projectalish sha
 
Attn list test
Attn list testAttn list test
Attn list testalish sha
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303alish sha
 
Final project
Final projectFinal project
Final projectalish sha
 

Mais de alish sha (20)

T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9T22016 – how to answer with ubs 9
T22016 – how to answer with ubs 9
 
July 2014 theory exam (theory)
July 2014 theory exam (theory)July 2014 theory exam (theory)
July 2014 theory exam (theory)
 
Accounting basic equation
Accounting basic equation Accounting basic equation
Accounting basic equation
 
It 302 computerized accounting (week 2) - sharifah
It 302   computerized accounting (week 2) - sharifahIt 302   computerized accounting (week 2) - sharifah
It 302 computerized accounting (week 2) - sharifah
 
It 302 computerized accounting (week 1) - sharifah
It 302   computerized accounting (week 1) - sharifahIt 302   computerized accounting (week 1) - sharifah
It 302 computerized accounting (week 1) - sharifah
 
What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)What are the causes of conflicts (Bahasa Malaysia)
What are the causes of conflicts (Bahasa Malaysia)
 
Lab 9 sem ii_12_13
Lab 9 sem ii_12_13Lab 9 sem ii_12_13
Lab 9 sem ii_12_13
 
Lab 10 sem ii_12_13
Lab 10 sem ii_12_13Lab 10 sem ii_12_13
Lab 10 sem ii_12_13
 
Lab 6
Lab 6Lab 6
Lab 6
 
Lab 5 2012/2012
Lab 5 2012/2012Lab 5 2012/2012
Lab 5 2012/2012
 
Purpose elaborate
Purpose elaboratePurpose elaborate
Purpose elaborate
 
Lab sheet 1
Lab sheet 1Lab sheet 1
Lab sheet 1
 
Test 1 alish schema 1
Test 1 alish schema 1Test 1 alish schema 1
Test 1 alish schema 1
 
Lab 6 sem ii_11_12
Lab 6 sem ii_11_12Lab 6 sem ii_11_12
Lab 6 sem ii_11_12
 
Test 1 skema q&a
Test 1 skema q&aTest 1 skema q&a
Test 1 skema q&a
 
Final project
Final projectFinal project
Final project
 
Final project
Final projectFinal project
Final project
 
Attn list test
Attn list testAttn list test
Attn list test
 
Carry markdam31303
Carry markdam31303Carry markdam31303
Carry markdam31303
 
Final project
Final projectFinal project
Final project
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Test 1 skema q&a

  • 1. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING TEST 1-MONDAY Write a program to calculate mass of the liquid in a tank. Allow the user to input the volume either in cm or meter, and prompt the user to recalculate if desire. Note that: Oil density (ρ)= 850 kg/m3 Mass=ρV The output should be similar to:
  • 2. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> #include<math.h> main(){ float oildensity, tankvolume,mass=0; char oilunit,again; printf("This program calculate the mass of oil in a tank"); start: printf("nnEnter oil density: ");scanf("%f",&oildensity); printf("Enter tank volume: ");scanf("%f",&tankvolume); printf("nEnter volume unit(m=meter, c=centimeter): ");scanf("%s",&oilunit); recalculate: switch (oilunit){ case 'c': mass= oildensity*((pow(tankvolume,3))/pow(100,3)); break; case 'm': mass= oildensity*(pow(tankvolume,3)); break; default: printf("You have entered a wrong type of unit"); printf("nnEnter oil density unit(g for gram/k for kg): ");scanf("%s",&oilunit); goto recalculate; } printf("nntThe Mass of oil is %.4fkg",mass); printf("nnDo you want to re-calculate: ");scanf("%s",&again); if(again=='y' || again=='Y') goto start; getch(); }
  • 3. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> #include<math.h> main(){ float oildensity, tankvolume,mass=0; char oilunit,again; printf("This program calculate the mass of oil in a tank"); start: printf("nnEnter oil density: ");scanf("%f",&oildensity); printf("Enter tank volume: ");scanf("%f",&tankvolume); printf("nEnter volume unit(m=meter, c=centimeter): ");scanf("%s",&oilunit); recalculate: if (oilunit== 'c'){ mass= oildensity*((pow(tankvolume,3))/pow(100,3)); } else if (oilunit== 'm'){ mass= oildensity*(pow(tankvolume,3));} else{ printf("You have entered a wrong type of unit"); printf("nnEnter oil density unit(g for gram/k for kg): ");scanf("%s",&oilunit); goto recalculate; } printf("nntThe Mass of oil is %.4fkg",mass); printf("nnDo you want to re-calculate(enter y for yes): ");scanf("%s",&again); if(again=='y' || again=='Y') goto start; getch(); }
  • 4. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ float oildensity, tankvolume,mass=0; char oilunit,again; printf("This program calculate the mass of oil in a tank"); start: printf("nnEnter oil density: ");scanf("%f",&oildensity); printf("Enter tank volume: ");scanf("%f",&tankvolume); printf("nEnter volume unit(m=meter, c=centimeter): ");scanf("%s",&oilunit); recalculate: switch (oilunit){ case 'c': mass= oildensity*(tankvolume/100); break; case 'm': mass= oildensity*tankvolume; break; default: printf("You have entered a wrong type of unit"); printf("nnEnter oil density unit(g for gram/k for kg): ");scanf("%s",&oilunit); goto recalculate; } printf("nntThe Mass of oil is %.4fkg",mass); printf("nnDo you want to re-calculate: ");scanf("%s",&again); if(again=='y' || again=='Y') goto start; getch(); }
  • 5. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ float oildensity, tankvolume,mass=0; char oilunit,again; printf("This program calculate the mass of oil in a tank"); start: printf("nnEnter oil density: ");scanf("%f",&oildensity); printf("Enter tank volume: ");scanf("%f",&tankvolume); printf("nEnter volume unit(m=meter, c=centimeter): ");scanf("%s",&oilunit); recalculate: if (oilunit== 'c'){ mass= oildensity*(tankvolume/100); } else if (oilunit== 'm'){ mass= oildensity*tankvolume;} else{ printf("You have entered a wrong type of unit"); printf("nnEnter oil density unit(g for gram/k for kg): ");scanf("%s",&oilunit); goto recalculate; } printf("nntThe Mass of oil is %.4fkg",mass); printf("nnDo you want to re-calculate(enter y for yes): ");scanf("%s",&again); if(again=='y' || again=='Y') goto start; getch(); }
  • 6. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING TEST 1-TUESDAY Base on the table develop a simple program on how long should a man/woman should exercise to burn calories off either by jogging or bicycling. The user must be able to keep calculating until the key end otherwise. Example: A 65kg woman needs to burn of 800 calories by jogging, how long does she need to jog in order to burn of all of the calories. ������������������������������������������������ ������������������������������������������������ 540 Energy output: ������������������������ℎ������ ������ Δ 64 x 68������������ 68 ������������������������������ ������������������������������������������������ 800 Duration: Δ ������������������������������������ ������������������������������������ 516.17 The output should be similar to :
  • 7. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ float calorin,weight,totalhour=0; int type; char again; printf("ttt444Exercise Calculator444nn"); start: printf("nEnter calories intake: ");scanf("%f",&calorin); printf("Enter your weight: ");scanf("%f",&weight); choose: printf("nPlease choose type of exercise n1. Joggingn2. BicyclingnPlease enter type: ");scanf("%d",&type); switch(type){ case 1: totalhour=calorin/(weight*(540/68)); printf("ntIn order to burn %.f of calories you need to jog for %.1fhr",calorin,totalhour);break; case 2: totalhour=calorin/(weight*(639/68)); printf("ntIn order to burn %.f of calories you need to cycle for %.1fhr",calorin,totalhour);break; default: goto choose;break; } if(again=='y' || again=='Y') goto start; getch(); }
  • 8. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ float calorin,weight,totalhour=0; int type; char again; printf("ttt444Exercise Calculator444nn"); start: printf("nEnter calories intake: ");scanf("%f",&calorin); printf("Enter your weight: ");scanf("%f",&weight); choose: printf("nPlease choose type of exercise n1. Joggingn2. BicyclingnPlease enter type: ");scanf("%d",&type); if (type==1){ totalhour=calorin/(weight*(540/68)); printf("ntIn order to burn %.f of calories you need to jog for %.1fhr",calorin,totalhour); } else if (type==2){ totalhour=calorin/(weight*(639/68)); printf("ntIn order to burn %.f of calories you need to cycle for %.1fhr",calorin,totalhour); } else { goto choose;} if(again=='y' || again=='Y') goto start; getch(); }
  • 9. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING TEST 1-TUESDAY Base on the table develop a simple program on how long should a man/woman should exercise to burn calories off either by jogging or playing tennis. The user must be able to keep calculating until the key end otherwise. Example: A 65kg woman needs to burn of 800 calories by jogging, how long does she need to jog in order to burn of all of the calories. ������������������������������������������������ ������������������������������������������������ 540 Energy output: ������������������������ℎ������ ������ Δ 64 x 68������������ 68 ������������������������������ ������������������������������������������������ 800 Duration: Δ ������������������������������������ ������������������������������������ 508.23 The output should be similar to :
  • 10. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ float calorin,weight,totalhour=0; int type; char again; printf("ttt444Exercise Calculator444nn"); start: printf("nEnter calories intake: ");scanf("%f",&calorin); printf("Enter your weight: ");scanf("%f",&weight); choose: printf("nPlease choose type of exercise n1. Joggingn2. TennisnPlease enter type: ");scanf("%d",&type); switch(type){ case 1: totalhour=calorin/(weight*(540/68)); printf("ntIn order to burn %.f of calories you need to jog for %.1fhr",calorin,totalhour);break; case 2: totalhour=calorin/(weight*(480/68)); printf("ntIn order to burn %.f of calories you need to play intense tennis for %.1fhr", calorin,totalhour); break; default: goto choose; break; } printf("nnDo you want to re-calculate(enter y for yes): ");scanf("%s",&again); if(again=='y' || again=='Y') goto start; getch(); }
  • 11. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ float calorin,weight,totalhour=0; int type; char again; printf("ttt444Exercise Calculator444nn"); start: printf("nEnter calories intake: ");scanf("%f",&calorin); printf("Enter your weight: ");scanf("%f",&weight); choose: printf("nPlease choose type of exercise n1. Joggingn2. TennisnPlease enter type: ");scanf("%d",&type); if(type==1){ totalhour=calorin/(weight*(540/68)); printf("ntIn order to burn %.f of calories you need to jog for %.1fhr",calorin,totalhour);} else if(type==2){ totalhour=calorin/(weight*(480/68)); printf("ntIn order to burn %.f of calories you need to play intense tennis for %.1fhr",calorin,totalhour); } else{ goto choose; } printf("nnDo you want to re-calculate(enter y for yes): ");scanf("%s",&again); if(again=='y' || again=='Y') goto start; getch(); }
  • 12. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING TEST 1-TUESDAY Base on the table develop a simple program on how long should a man/woman should exercise to burn calories off either by fast swimming or bicycling. The user must be able to keep calculating until the key end otherwise. Example: A 65kg woman needs to burn of 800 calories by jogging, how long does she need to jog in order to burn of all of the calories. ������������������������������������������������ ������������������������������������������������ 540 Energy output: ������������������������ℎ������ ������ Δ 64 x 68������������ 68 ������������������������������ ������������������������������������������������ 800 Duration: Δ ������������������������������������ ������������������������������������ 508.23 The output should be similar to :
  • 13. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ float calorin,weight,totalhour=0; int type; char again; printf("ttt444Exercise Calculator444nn"); start: printf("nEnter calories intake: ");scanf("%f",&calorin); printf("Enter your weight: ");scanf("%f",&weight); choose: printf("nPlease choose type of exercise n1. Fast Swimmingn2. BicyclingnPlease enter type: ");scanf("%d",&type); switch(type){ case 1: totalhour=calorin/(weight*(860/68)); printf("ntIn order to burn %.f of calories you need to fast swimming for %.1fhr",calorin,totalhour);break; case 2: totalhour=calorin/(weight*(639/68)); printf("ntIn order to burn %.f of calories you need to cycle for %.1fhr",calorin,totalhour); break; default: goto choose;break; }
  • 14. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ float calorin,weight,totalhour=0; int type; char again; printf("ttt444Exercise Calculator444nn"); start: printf("nEnter calories intake: ");scanf("%f",&calorin); printf("Enter your weight: ");scanf("%f",&weight); choose: printf("nPlease choose type of exercise n1. Fast Swimmingn2. BicyclingnPlease enter type: ");scanf("%d",&type); if(type==1){ totalhour=calorin/(weight*(860/68)); printf("ntIn order to burn %.f of calories you need to fast swimming for %.1fhr", calorin,totalhour);} else if (type==2){ totalhour=calorin/(weight*(639/68)); printf("ntIn order to burn %.f of calories you need to cycle for %.1fhr",calorin,totalhour); } else{ goto choose; } if(again=='y' || again=='Y') goto start; getch(); }
  • 15. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING TEST 1-WEDNESDAY Develop a simple program to calculate radius of a circle. The user need to choose whether to input area or circumference of the circle. Note that: area= πxrad2 and circumference = 2xπxrad The output should be similar to: The user must be able to keep calculating until the key end otherwise.
  • 16. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> #include<math.h> #define PI 3.1416 main(){ char type,again; float radius,circumference,area; printf("t444This program calculate radius of a circle444"); start: printf("nna:areanc:circumferencennEnter the information that you have:"); scanf("%s",&type); cal: switch(type){ case 'a': printf("nEnter area of a circle:");scanf("%f",&area); radius = sqrt(area/PI); printf("nThe area of a circle is %.2f while the radius is %.4f",area,radius); break; case 'c': printf("nEnter circumference of a circle:");scanf("%f",&circumference); radius= circumference/(PI*2); printf("nThe circumference of a circle is %.2f while the radius is %.4f",circumference,radius);break; default: printf("na:areanc:circumferencennPlease re-enter selection:"); scanf("%s",&type); goto cal; } if(again=='y' || again=='Y') { goto start;} getch(); }
  • 17. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> #include<math.h> #define PI 3.1416 main(){ char type,again; float radius,circumference,area; printf("t444This program calculate radius of a circle444"); start: printf("nna:areanc:circumferencennEnter the information that you have:"); scanf("%s",&type); cal: if (type=='a'){ printf("nEnter area of a circle:");scanf("%f",&area); radius = sqrt(area/PI); printf("nThe area of a circle is %.2f while the radius is %.4f",area,radius);} else if(type== 'c'){ printf("nEnter circumference of a circle:");scanf("%f",&circumference); radius=circumference/(PI*2); printf("nThe circumference of a circle is %.2f while the radius is %.4f",circumference,radius);} else{ printf("na:areanc:circumferencennPlease re-enter selection:"); scanf("%s",&type); goto cal;} if(again=='y' || again=='Y') goto start; getch(); }
  • 18. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING TEST 1-WEDNESDAY Develop a simple program to calculate either an area or perimeters of a semi circle. The program must prompt the user to input radius. Note that: area= πxrad2 and circumference = 2xπxrad The output should be similar to : 20.7075 The user must be able to keep calculating until the key end otherwise.
  • 19. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> #define PI 3.1415 main(){ char type,again; float radius,circumference,area,perimeters; printf("t444SEMI-CIRCLE CALCULATOR444"); start: printf("na:areanp:perimetersnnEnter selection:"); scanf("%s",&type); printf("nEnter radius of the semi-circle:"); scanf("%f",&radius); cal: switch(type){ case 'a': area= 0.5*(PI*pow(radius,2)); printf("nThe area of a semi-circle for %.2f radius is %.4f",radius,area); break; case 'p': circumference= 2*PI*radius; perimeters= (2 *radius)+ (circumference/2); printf("nThe perimeters of a semi-circle for %.2f of radius is %.4f",radius,perimeters);break; default: printf("wrong selection"); printf("na:areanp:PerimetersnnPlease re-enter selection:"); scanf("%s",&type); goto cal; } if(again=='y' || again=='Y') goto start; getch(); }
  • 20. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> #define PI 3.1415 main(){ char type,again; float radius,circumference,area,perimeters; printf("t444SEMI-CIRCLE CALCULATOR444"); start: printf("na:areanp:perimetersnnEnter selection:"); scanf("%s",&type); printf("nEnter radius of the semi-circle:"); scanf("%f",&radius); cal: if(type=='a'){ area= 0.5*(PI*pow(radius,2)); printf("nThe area of a semi-circle for %.2f radius is %.4f",radius,area);} else if(type=='p'){ circumference= 2*PI*radius; perimeters= (2 *radius)+ (circumference/2); printf("nThe perimeters of a semi-circle for %.2f of radius is %.4f",radius,perimeters);} else{ printf("wrong selection"); printf("na:areanp:PerimetersnnPlease re-enter selection:"); scanf("%s",&type); goto cal; } if(again=='y' || again=='Y') goto start; getch(); }
  • 21. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING TEST 1-THURSDAY Write a program to prove the theory of prefix and postfix in C Program slybuss. Allow the user to keep testing until ‘n’ is keyed in by the user Note that: Postfix : a++,a— Prefix :++a,--a The output should be similar to:
  • 22. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ int a,prepost; char b; printf("tThis program is use to proof theory of postfix and prefix"); sekalilagi: printf("nnEnter value a: "); scanf("%d",&a); choose: printf("nPlease choosen1. postfixn2. PrefixnPlease enter your choice: "); scanf("%d",&prepost); switch (prepost){ case 1: printf("npostfix/a++ for a is %d at the end a =%d", a++,a); printf("nand a after ; is %d",a); printf("nnpostfix/a-- for a is %d at the end a =%d", a--,a); printf("nand a after ; is %d",a); break; case 2: printf("nprefix/++a for a = %d at the end a =%d", ++a,a); printf("nand a after ; is %d",a); printf("nnprefix/--a for a = %d at the end a =%d", --a,a); printf("nand a after ; is %d",a); break; default: goto choose; } printf("nnEnter n to stop re-trying: "); scanf("%s",&b); if (b!='n'){ goto sekalilagi;} getch(); }
  • 23. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> main(){ int a,prepost; char b; printf("tThis program is use to proof theory of postfix and prefix"); sekalilagi: printf("nnEnter value a: "); scanf("%d",&a); choose: printf("nPlease choosen1. postfixn2. PrefixnPlease enter your choice: "); scanf("%d",&prepost); if (prepost==1){ printf("npostfix/a++ for a is %d at the end a =%d", a++,a); printf("nand a after ; is %d",a); printf("nnpostfix/a-- for a is %d at the end a =%d", a--,a); printf("nand a after ; is %d",a); } else if (prepost==2){ printf("nprefix/++a for a = %d at the end a =%d", ++a,a); printf("nand a after ; is %d",a); printf("nnprefix/--a for a = %d at the end a =%d", --a,a); printf("nand a after ; is %d",a);} else { goto choose;} printf("nnEnter n to stop re-trying: "); scanf("%s",&b); if (b!='n'){ goto sekalilagi;} getch(); }
  • 24. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING TEST 1-FRIDAY Write a program to segregat number of students according to : GRADE E: 0 <= mark <=49 GRADE D: 50 <=mark <=59 GRADE C: 60 <= mark <=69 GRADE B: 70 <= mark <=79 GRADE A: 80 <= mark <=100 The output should be similar to:
  • 25. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> int main(){ int noofstudent=0,mark=0, gradeA=0,gradeB=0,gradeC=0,gradeD=0,gradeE=0; int i=1; printf("44The Program segregrate the number of students according to grade44 "); printf("nnEnter Number of student: "); scanf ("%d",&noofstudent); loop: printf("%d student mark: ",i); scanf ("%d",&mark); if (mark>=0 && mark <=49) { gradeE++; } else if (mark>=50 && mark <=59) { gradeD++; } else if (mark>=60 && mark <=69) { gradeC++; } else if (mark>=70 && mark <=79) { gradeB++; } else if (mark>=80 && mark <=100) { gradeA++; } i++; if (i<noofstudent) goto loop;
  • 26. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING printf("n______________________________________________n "); printf("nThere is %d students receive grade A ",gradeA); printf("nThere is %d students receive grade B ",gradeB); printf("nThere is %d students receive grade C ",gradeC); printf("nThere is %d students receive grade D ",gradeD); printf("nThere is %d students receive grade E ",gradeE); getch(); return 0; }
  • 27. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING TEST 1-FRIDAY Develelope a simple program which receive radius of a circle from user and allowed user to choose between calculating area of a circle or circumferense of a circle,: Note that: area= πxrad2 and circumference = 2xπxrad The output should be similar to : The user must be able to keep calculating until the key end otherwise.
  • 28. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> #include<math.h> #define PI 3.1416 main(){ char type,b; float radius,circumference,area; printf("This program calculate Area or Circumference of a circle"); again: printf("na:areanc:circumferencennEnter selection:");scanf("%s",&type); printf("nEnter radius of a circle:"); scanf("%f",&radius); cal: switch(type){ case 'a': area= PI*pow(radius,2); printf("nThe area of a circle for %.2fcm radius is %.4f",radius,area); break; case 'c': circumference= 2*PI*radius; printf("nThe circumference of a circle for %.2fcm radius is %.4f",radius,circumference);break; default: printf("wrong selection"); printf("na:areanc:circumferencennPlease re-enter selection:"); scanf("%s",&type); goto cal; } printf("nnEnter n to stop re-trying: "); scanf("%s",&b); if (b!='n'){ goto again;} getch(); }
  • 29. UNIVERSITI TUN HUSSEIN ONN MALAYSIA FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING BTI10202 COMPUTER PROGRAMMING #include<stdio.h> #include<conio.h> #include<math.h> #define PI 3.1416 main(){ char type,b; float radius,circumference,area; printf("This program calculate Area or Circumference of a circle"); again: printf("na:areanc:circumferencennEnter selection:"); scanf("%s",&type); printf("nEnter radius of a circle:"); scanf("%f",&radius); cal: if (type=='a'){ area= PI*pow(radius,2); printf("nThe area of a circle for %.2fcm radius is %.4f",radius,area); } else if (type=='c') { circumference= 2*PI*radius; printf("nThe circumference of a circle for %.2fcm radius is %.4f",radius,circumference);} else { printf("wrong selection"); printf("na:areanc:circumferencennPlease re-enter selection:"); scanf("%s",&type); goto cal; } printf("nnEnter n to stop re-trying: "); scanf("%s",&b); if (b!='n'){ goto again;} getch(); }