Professional Documents
Culture Documents
COMP 213:
C LANGUAGE PROGRAMMING
PROJECTS
SUBMITTED BY:
KEVEN VINCENT P. GUANZON
BS-AeE 2-2
PRELIMINARIES
#include <stdio.h>
float a,c;
main()
{
printf("Enter the amount in dollars:");
scanf("%f",&a);
c=a*45.00;
printf("\nThe value in peso is %f \n",c);
printf("\nKeven Vincent P. Guanzon Future
Engineer :)");
return 0;
}
OUTPUT:
SOURCE CODE
#include <stdio.h>
float p,y, s, d;
main()
{
printf("Enter the purchase price of the item:");
scanf("%f",&p);
printf("\nEnter the life expectancy of the item:");
scanf("%f",&y);
printf("\nEnter the salvage value of the item:");
scanf("%f",&s);
d=(p-s)/y;
printf("\nThe yearly depreciation rate of the item is:
%2f \n", d);
printf("\nKeven Vincent P. Guanzon Future
Engineer :)");
return 0;
}
OUTPUT:
OPERATORS PROGRAM
SOURCE CODE
#include <stdio.h>
#include <stdio.h>
int main()
{
int a=41,b=20, add,sub,mul,div,mod;
add = a+b;
sub = a-b;
mul = a*b;
div = a/b;
mod = a%b;
printf("The sum of a and b is: %d\n", add);
printf("\nThe difference of a and b is: %d\n", sub);
printf("\nThe product of a and b is: %d\n", mul);
printf("\nThe Quotient of a and b is: %d\n", div);
printf("\nThe remainder of a and b is: %d\n", mod);
printf("\nKeven Vincent P. Guanzon Future Engineer :)");
return 0;
}
OUTPUT:
return 0;
OUTPUT:
MIDTERMS
{
char z;
printf("Enter grade here (Must be A, B, C, D, or F): ");
scanf("%c", &z);
switch( z )
{
case 'a' : printf( "\nExcellent\n" );break;
case 'b' : printf( "\nGood\n" ); break;
case 'c' : printf( "\nOK\n" ); break;
case 'd' : printf( "\nMmmmm....\n" ); break;
case 'f' : printf( "\nYou must do better than this\n" );
break;
default : printf( "\nWhat is your grade anyway?\n" );
break;
}
printf("Keven Vincent Guanzon Future Engineer!");
return 0;
}
OUTPUT:
SOURCE CODE
#include <stdio.h>
int main(){
int num;
printf("Enter a number you want to check.\n");
scanf("%d",&num);
if((num%2)==0)
//checking whether remainder is
0 or not.
printf("%d is even.",num);
else
printf("%d is odd.",num);
return 0;
}
OUTPUT:
SOURCE CODE
#include<stdio.h>
#include<string.h>
#include<conio.h>
main()
{
char a[10]
[10]={"ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","
EIGHT","NINE"};
char b[10]
[10]={"ELEVEN","TWELVE","THIRTEEN","FOURTEEN","FIFTEE
N","SIXTEEN","SEVENTEEN","EIGHTEEN","NINTEEN"};
char c[10]
[10]={"TEN","TWENTY","THIRTY","FOURTY","FIFTY","SIXTY",
"SEVENTY","EIGHTY","NINTY"};
char d[10][10] = {"THOUSAND"};
char e[10][10] = {"HUNDRED "};
int no,t;
printf("Enter a postive number:");
scanf("%d",&no);
if(no<3001)
{
if(no>1000)
{
t=no/1000;
no=no%1000;
printf("%s %s",a[t-1], d);
}
if(no>=100)
{
t=no/100;
no=no%100;
printf(" %s %s",a[t-1],e);
}
if(no>=10 && no<20)
{
t=no-10;
printf(" %s",b[t-1]);
}
if(no>19 && no<100)
{
t=no/10;
no=no%10;
printf("%s",c[t-1]);
}
if(no<10)
{
printf(" %s",a[no-1]);
}
}
else
printf("Enter smaller number");
printf("\nKeven Vincent Guanzon Future Engineer! :)");
return 0;
}
OUTPUT:
CONCATENATION PROGRAM
SOURCE CODE
#include <stdio.h>
#include <string.h>
main()
{
char a[1000], b[1000];
printf("Enter the first string\n");
gets(a);
printf("Enter the second string\n");
gets(b);
strcat(a,b);
printf("String obtained on concatenation is %s\n",a);
printf("Keven Vincent Guanzon Future Engineer! :)");
return 0;
}
OUTPUT:
FINALS
#include <stdio.h>
int main()
{
int n, count, sum=0;
printf("Enter an integer: ");
scanf("%d",&n);
count=1;
while(count<=n)
{
sum+=count;
++count;
}
printf("Sum = %d",sum);
printf("\nTherefore,Keven Guanzon is very pogi AHAHA");
return 0;
}
OUTPUT:
DISPLAYING NUMBERS
SOURCE CODE
#include<stdio.h>
int n;
main(){
do{
printf("%d",n);
n++;
}while (n<=5);
Printf(Ken Ken);
return 0;
}
OUTPUT:
#include <stdio.h>
main()
{
int n,i;
printf("Enter a positive integer: ");
scanf("%d",&n);
printf("Factors of %d are: ", n);
for(i=1;i<=n;++i)
{
if(n%i==0)
printf("%d ",i);
}
printf("\nKeven Guanzon is Awesome");
return 0;
}
OUTPUT:
REVERSING A NUMBER
SOURCE CODE
#include <stdio.h>
OUTPUT: