university of the east

12
University of the East College Of Engineering Machine Problem #2 --- C Language --- Submitted by: Francisco, Rome John S. 2011-11-43658 Submitted to: Mr. Joan Lazaro July 23, 2012 GRADE 2.1 Make a program that will display “I will pass PROGRAMMING!”

Upload: clarice-francisco

Post on 26-Oct-2014

104 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: University of the East

University of the East

College Of Engineering

Machine Problem #2

--- C Language ---

Submitted by:

Francisco, Rome John S.

2011-11-43658

Submitted to:

Mr. Joan Lazaro

July 23, 2012

GRADE

Page 2: University of the East

2.1 Make a program that will display “I will pass PROGRAMMING!”

#include<stdio.h>

#include<conio.h>

main()

{

printf("I will pass PROGRAMMING!");

getch();

}

2.2 Design a program in C language that will display “#” at every corners of the screen.

#include<stdio.h>

Page 3: University of the East

#include<conio.h>

main()

{

printf("#\t\t\t\t\t\t\t\t\t#");

printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n#\t\t\t\t\t\t\t\t\t#");

getch();

}

2.3 Construct a program that will display your name, address and contact number on the upper left corner

of the screen.

#include<conio.h>

main()

{

Page 4: University of the East

char name[30], add[40], cnum[15];

printf("Your Name:");

gets(name);

printf("Your Address:");

gets(add);

printf("Your Contact Number:");

gets(cnum);

getch();

}

2.4 Create a program in C language that will input temp. in Celsius and display the equivalent value in

Fahrenheit.

#include<stdio.h>

#include<conio.h>

main()

{

float F, C;

Page 5: University of the East

printf("Enter the temperature in Celsius:");

scanf("%f", &C);

F=C*9/5+32;

printf("The Temperature in Farenheit:%.2f", F);

getch();

}

2.5 Write a program that will input length in inches and output the equivalent in meters.

#include<stdio.h>

#include<conio.h>

main()

{

float i, cm, m;

printf("Enter the length in inches:");

scanf("%f", &i);

cm=i*2.54;

Page 6: University of the East

m=cm/100;

printf("The length in metres: %.4f meters", m);

getch();

}

2.6 At the University of the East, every unit is worth in enrollment fee. An additional 15% of this amount is

paid in misc. fee with a blanket fee of P200 regardless of the load.

#include<stdio.h>

#include<conio.h>

main()

{

int unit;

float ad, total;

printf("Enter the number of units enrolled:");

scanf("%d", &unit);

unit=unit*45;

ad=unit*.15;

Page 7: University of the East

total=unit+ad+200;

printf("Your tuition fee to be paid: %.3f", total);

getch();

}

2.7 A car ravels at a constant speed of 50 km/hr. make a program that will input time in mins. That the trip

took and output the distance in km that the car travel.

#include<stdio.h>

#include<conio.h>

main()

{

int time;

float dis, vel, km;

printf("Enter the time in minutes:");

scanf("%d", &time);

vel=(50*1000)/60;

dis=time*vel;

km=dis/1000;

printf("The distance in kilometers: %.1f kilometers", km);

Page 8: University of the East

getch();

}

2.8 A taxi charges a fixed rate of P1.25 for every 250 m that it travels. Create a program in C language that

will input the distance in km that the taxi travel and output the cost of the trip.

#include<stdio.h>

#include<conio.h>

main()

{

float km, m, cost;

printf("Enter the distance you traveled in kilometers:");

scanf("%f", &km);

m=km*1000;

cost=m/200;

printf("The cost of the trip is: %.2f pesos", cost);

getch();

}

Page 9: University of the East

2.9 Create a program that will input two integers variables, A and B and exchange their values.

#include<stdio.h>

#include<conio.h>

main()

{

float A, B,C;

printf("Enter the first integer:");

scanf("%f", &A);

printf("Enter the second integer:");

scanf("%f", &B);

C=A;

A=B;

B=C;

printf("The new value of first integer is: %.2f", A);

printf("\nThe new value of second integer is: %.2f", B);

getch();

Page 10: University of the East

}

2.10 A store sells soft drinks for P2.25 and sandwiches for P6.85. Construct a program that will input the

no. of drinks and sandwiches a customer bought and the bill.

#include<stdio.h>

#include<conio.h>

main()

{

int sf, sw;

float costsf, costsw, bill;

printf("Enter the number of softdrinks:");

scanf("%d", &sf);

printf("Enter the number of sandwiches:");

scanf("%d", &sw);

costsf=sf*2.25;

costsw=sw*6.85;

bill=costsw+costsf;

printf("The cost of the softdrinks is: %.2f pesos", costsf);

printf("\nThe cost of the sandwiches is: %.2f pesos", costsw);

printf("\nThe total costs of the items is: %.2f pesos", bill);

getch();

}

Page 11: University of the East