Tuesday, October 18, 2011

Review Program

#include
#include

int x,y,z,m;

int main()
{
printf("Enter Number: ");
scanf("%d",&y);
printf("Enter another Number: ");
scanf("%d",&z);

for(x = 1; x <= y; x++)
{
m = y * z;
printf("%d x %d = %d\n",y,z,m);

}
getch();
return 0;
}

Thursday, October 13, 2011


/* Program to reverse the digits of a number */

#include

#include

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;

}

Monday, October 10, 2011

#include

#include

int choice,quantity,Bill,cash,ans;

char option;

int main()

{

printf("\nValue Meal");

printf("\n1.] Burger Fries w/ Drinks 59.00");

printf("\n1.] Hotdog w/ Drinks 59.00");

printf("\nEnter Choice: ");

scanf("%d",&choice);

switch (choice)

{

case 1:

printf("Enter Quantity: ");

scanf("%d",&quantity);

printf("\nUpgrade [Y/N]: ");

scanf("%s",&option);

if (option == 'y')

{

Bill = quantity * 59 + 15;

printf("\nYour total Bill is %d",Bill);

printf("\nEnter Cash: ");

scanf("%d",&cash);

ans = cash - Bill;

printf("Your change is %d",ans);

}

if (option == 'n')

{

Bill = quantity * 59;

printf("\nYour total Bill is %d :",Bill);

printf("\nEnter Cash: ");

scanf("%d",&cash);

ans = cash - Bill;

printf("Your change is %d", ans);

break;

case 2:

printf("Enter Quantity: ");

scanf("%d",&quantity);

printf("\nUpgrade [Y/N]: ");

scanf("%s",&option);

if (option == 'y')

{

Bill = quantity * 59 + 15;

printf("\nYour total Bill is %d",Bill);

printf("\nEnter Cash: ");

scanf("%d",&cash);

ans = cash - Bill;

printf("Your change is %d",ans);

}

if (option == 'n')

{

Bill = quantity * 59;

printf("\nYour total Bill is %d :",Bill);

printf("\nEnter Cash: ");

scanf("%d",&cash);

ans = cash - Bill;

printf("Your change is %d", ans);

break;

}

}

}

getch();

return 0;

}

Sunday, October 9, 2011

Will display even numbers

#include
#include

int main()
{
int i,y;
printf("Enter Number: ");
scanf("%d",&y);
for (i=0; i<=y; i+=2)
{
printf ("%d\n",i);
}

getch();
return 0;
}

Saturday, October 8, 2011

Pizza Order

Example 3-2: Pizza Order

1. Start a new project. We'll build a form where a pizza order can be entered by simply clicking on check boxes and option buttons.

2. Draw three frames. In the first, draw three option buttons, in the second, draw two option buttons, and in the third, draw six check boxes. Draw two option buttons on the form. Add two command buttons. Make things look something like this.



3. Set the properties of the form and each control.

Form1:

BorderStyle

1-Fixed Single


Caption

Pizza Order


Name

frmPizza

Frame1:

Caption

Size

Frame2:

Caption

Crust Type

Frame3:

Caption

Toppings

Option1:

Caption

Small


Name

optSize


Value

True

Option2:

Caption

Medium


Name

optSize (yes, create a control array)

Option3:

Caption

Large


Name

optSize

Option4:

Caption

Thin Crust


Name

optCrust


Value

True

Option5:

Caption

Thick Crust


Name

optCrust (yes, create a control array)

Option6:

Caption

Eat In


Name

optWhere


Value

True

Option7:

Caption

Take Out


Name

optWhere (yes, create a control array)

Check1:

Caption

Extra Cheese


Name

chkTop

Check2:

Caption

Mushrooms


Name

chkTop (yes, create a control array)

Check3:

Caption

Black Olives


Name

chkTop

Check4:

Caption

Onions


Name

chkTop

Check5:

Caption

Green Peppers


Name

chkTop

Check6:

Caption

Tomatoes


Name

chkTop

Command1:

Caption

&Build Pizza


Name

cmdBuild

Command2:

Caption

E&xit


Name

cmdExit

The form should look like this now:

















4. Declare the following variables in the general declarations area:

Option Explicit
Dim PizzaSize As String
Dim PizzaCrust As String
Dim PizzaWhere As String


This makes the size, crust, and location variables global to the form.

5. Attach this code to the Form_Load procedure. This initializes the pizza size, crust, and eating location.

Private Sub Form_Activate()


PizzaSize = "Small"
PizzaCrust = "Thin Crust"
PizzaWhere = "Eat In"

End Sub

Here, the global variables are initialized to their default values, corresponding to the default option buttons.

6. Attach this code to the three option button array Click events. Note the use of the Index variable:

Private Sub optSize_Click(Index As Integer)


PizzaSize = optSize(Index).Caption

End Sub

Private Sub optCrust_Click(Index As Integer)


PizzaCrust = optCrust(Index).Caption

End Sub

Private Sub optWhere_Click(Index As Integer)


PizzaWhere = optWhere(Index).Caption

End Sub

In each of these routines, when an option button is clicked, the value of the corresponding buttons caption is loaded into the respective variable.

7. Attach this code to the cmdBuild_Click event.

Private Sub cmdBuild_Click()

'This procedure builds a message box that displays your pizza type
Dim Message As String
Dim I As Integer
Message = PizzaWhere + vbCr
Message = Message + PizzaSize + " Pizza" + vbCr
Message = Message + PizzaCrust + vbCr
For I = 0 To 5

If chkTop(I).Value = vbChecked Then Message = Message + chkTop(I).Caption + vbCr

Next I
MsgBox Message, vbOKOnly, "Your Pizza"

End Sub

This code forms the first part of a message for a message box by concatenating the pizza size, crust type, and eating location (vbCr is a symbolic constant representing a �carriage return� that puts each piece of ordering information on a separate line). Next, the code cycles through the six topping check boxes and adds any checked information to the message. The code then displays the pizza order in a message box.

8. Attach this code to the cmdExit_Click event.

Private Sub cmdExit_Click()

End

End Sub

9. Get the application working. Notice how the different selection buttons work in their individual groups. Save your project.


Source : Click Me







Friday, October 7, 2011

#include
int main(){
int x,y;
printf("Enter value for x :");
scanf("%d",&x);
printf("Enter value for y :");
scanf("%d",&y);
if ( x > y ){
printf("X is large number - %d\n",x);
}
else{
printf("Y is large number - %d\n",y);
}
return 0;
}

Thursday, October 6, 2011

IT 403

1. Create a simple POS program that will compute the quantity order by the customer of a food store. Kindly refer to the sample output below:


Condition:

If upgrade is yes add 15 to total bill

Sunday, October 2, 2011

Solution # 8

#include
#include

int choice,p,a,b,c,area,base, height;

int main()
{
printf("This program will get the perimeter and are of Triangle\n");
printf("Choices\n");
printf("1.] Perimeter\n");
printf("2.] Area\n");
printf("Enter Choice [1 or 2]: ");
scanf("%d",&choice);

if (choice == 1)
{
printf("Enter Side A: ");
scanf("%d",&a);
printf("Enter Side B: ");
scanf("%d",&b);
printf("Enter Side C: ");
scanf("%d",&c);
p = a + b + c;
printf("The perimeter of the area of a triangle is %d",p);
}

if (choice == 2)
{
printf("Enter Base: ");
scanf("%d",&base);
printf("Enter Height: ");
scanf("%d",&height);
area = (base * height)/2;
printf("The area of a triangle is %d",area);
}
getch();
return 0;
}


Saturday, October 1, 2011

Checkbox & radio buttons


Change the following properties refer the table below





Following code is typed in the Click() events of the CheckBoxes

Private Sub chkBold_Click()
If chkBold.Value = 1 Then
txtDisplay.FontBold = True
Else
txtDisplay.FontBold = False
End If
End Sub

Private Sub chkItalic_Click()
If chkItalic.Value = 1 Then
txtDisplay.FontItalic = True
Else
txtDisplay.FontItalic = False
End If
End Sub

Private Sub chkUnderline_Click()
If chkUnderline.Value = 1 Then
txtDisplay.FontUnderline = True
Else
txtDisplay.FontUnderline = False
End If
End Sub

Following code is typed in the Click() events of the OptionButtons

Private Sub optBlue_Click()
txtDisplay.ForeColor = vbBlue
End Sub

Private Sub optRed_Click()
txtDisplay.ForeColor = vbRed
End Sub

Private Sub optGreen_Click()
txtDisplay.ForeColor = vbGreen
End Sub

To terminate the program following code is typed in the Click() event of the Exit button

Private Sub cmdExit_Click()
End
End Sub

Run the program by pressing F5. Check the program by clicking on OptionButtons and CheckBoxes.

Followers

Visitor

free counters

FEEDJIT Live Traffic Feed