August 30, 2009

Links for C compilers (specifically Turbo C and Quincy 2005)

For Quincy 2005
http://www.codecutter.net/tools/quincy/

For Turbo C
http://edn.embarcadero.com/article/20841

They are both c compilers. but the difference between the two compilers is that Turbo C is a little bit more strict in terms of coding than Quincy 2005. as what my teacher have said to us. There is one case wherein in Quincy 2005, you can run the program without the Return value and doesn't display an error message if logical error is committed like this for example 90< x >180. As what my teacher have said it is a logical error if you type it like that in the example. you usually don't get the exact result. To be also honest with you guys, I often don't used Turbo C in my programming because it is not user friendly. But I have tried it many times as often.

Functions

====================================================
#include <>
#include <>

int main ()
{
//Local Declarations
int a;
int b;
//Statements
printf("Square root of");
scanf("%d",&a);
b=sqrt(a);
printf("%d is the square root of %d",b,a);
return 0;
}

=================================================================
#include <>
#include <>

//Function Declarations
int square (int x);


int main ()
{
//Local Declarations
int a;
int b;
//Statements
printf("Square root of");
scanf("%d",&a);
b=square(a);
printf("%d is the square root of %d",b,a);
return 0;
}
int square (int x)
{
//Statements
return (sqrt(x));
}
====================================================================

August 24, 2009

How to manually remove a virus from a removable drive without using an antivirus program

Courtesy of youtube.
you can watch this also at http://www.youtube.com/watch?v=pVlLOPcO7cM


NOTE: Don't try to open the infected removable drive.
For it will no longer be useful to use this technique if the virus had infected your computer.(^_^)

Project 62 (Menu-driven program)

62. Write a menu-driven program that allows a user to enter five numbers and then choose between finding the smallest, largest, sum or average. The menu and all the choices are to be functions. Use a switch statement to determine what action to take. Provide an error message if an invalid choice is entered.

OUTPUT PROGRAM

Start of the Program


Option 1

Option 2



Option 3


Option 4

Default message

August 23, 2009

The Parking Lot Problem (Sample Output)

Sorry I removed the codes. I will post the code after i made some improvements on the code.
For you to have a simple style of code
But Here's the sample output:

Option 'c' or the "Car" vehicle type




Option 't' or the "Truck vehicle type.



Option 'b' or the "Truck" vehicle type.

The Parking Lot problem. (c source code)





August 20, 2009

Guessing game (c program code)

#include
int main ()
{
int n;
const int guess=10;
int flag=0;
printf("Guess the number that i am thinking\n");
scanf("%d",&n);
if (!(n>=guess))
printf("Your number is too low. try again\n");
else if (n>guess)
printf("Your number is too high. Try again\n");
else
flag=1;
if (flag==0)
scanf("%d",&n);
if (!(n>=guess))
printf("Your number is too low. try again\n");
else if (n>guess)
printf("Your number is too high. Try again\n");
else
flag=1;

if (flag==0)
scanf("%d",&n);
if (!(n>=guess))
printf("Your number is too low. try again\n");
else if (n>guess)
printf("Your number is too high. Try again\n");
else
flag=1;

if (flag==0)
scanf("%d",&n);
if (!(n>=guess))
printf("Your number is too low. try again\n");
else if (n>guess)
printf("Your number is too high. Try again\n");
else
flag=1;

if (flag==0)
scanf("%d",&n);
if (!(n>=guess))
printf("Your number is too low. try again\n");
else if (n>guess)
printf("Your number is too high. Try again\n");
else
flag=1;



if (flag==1)
printf("Congrats\n");
else
printf("im sorry!");
return 0;
}

This a simple guessing game program that was written using Quincy. Instead of using random function I intialized the guess to 10 wherein the number to be guessed is 10. and rather using a loop I used the if and else statements. The user is given 5 tries to guess the number. After 5 tries the program will display the "im sorry!". NOTE: I have change the expression statements in the if...

RESULTS


Start of the program...






*The program displays "Congrats" after successfully guessing the number.



*The program still continues to give the user a chance to guess the number.



*The program terminates after five tries had been given to the user.. and displays the "im sorry" message..