Do what you want to

do,Dream what you want to dream, Go where you want to go, Be what you want to be, because you only have one life and one chance to do all the things you want to do...


Showing posts with label C programming. Show all posts
Showing posts with label C programming. Show all posts

Sunday, December 23, 2012

Buat sifir guna Turbo C++


#include<stdio.h>
#include<conio.h>
#define size_of_box 40

main()
{
 int time, number, answer, i, j;

 //top line
 printf("%c",201);
 for (i=0; i<size_of_box; i++)
printf("%c", 205);
 printf("%c", 187);

 /*sides of box*/
 for (i=0; i<size_of_box; i++)
 {
printf("\n%c", 186);

printf("    Enter number between 1 and 12: ");
scanf("%d",&time);
printf("\n%8d times multiplication table\n", time);
for(number=1; number<=12; number++)
 {
answer=number*time;
printf("\n%16d x %d = %d", number,time, answer);
 }
for (j=0; j<size_of_box; j++)

printf(" ");
printf("%c",186);
}

//bottom line
 printf("\n%c", 200);
 for (i=0; i<size_of_box; i++)
printf("%c", 205);
 printf("%c",188);
 getch();
 return(0);
}

Friday, December 21, 2012

Sample programming project


This program using Turbo C++ ..


#include <stdio.h>
#include <conio.h>
#include <string.h>


void freemenu();
void menu();
void customer();
void choice();
void receipt();
void free();
void bigbody ();

int back, quantity, oder, sodder, fcode, freecake;
float sum, total;
char select, name[40], phone[11], ordate[9], item[30], chker, buf[5] ;
float a=10, b=20, c=30, d=5, e=55, f=89, g=100, h=120;



void main()
{
bigbody(); //please refer to void bigbody() for full code
}






void freemenu()
// Free gift Menu Data
{
printf("\n---------------------------------------------------------------------------");

printf("\n100.cake    \t\tKek Strawberi\t\t 50\t\t1kg");
printf("\n101.cake    \t\tKek Pisang\t\t 40\t\t1kg");
printf("\n102.cake    \t\tKek Durian\t\t 60\t\t1kg");
printf("\n103.cake    \t\tKek Keledek\t\t 45\t\t1kg");

printf("\n---------------------------------------------------------------------------");
}



void menu ()
// Menu Data
{
clrscr();

printf("\n\t\t\t===================================\n");
printf("\t\t\t**  \t Resepi Rahsio \t\t **\n");
printf("\t\t\t===================================\n\n");
// Menu
printf("\n---------------------------------------------------------------------------");
printf("\n\t\t\t\t Resepi Rahsio Corner ");
printf("\n\n  category\t\tItem Name\t\t Price\t\tpcs/weight");
printf("\n1.cookies \t\tBiskut Merry Ba\t\t 10\t\t50pcs");
printf("\n2.cookies \t\tBiskut Tiger Go\t\t 20\t\t50pcs");
printf("\n3.cookies \t\tBiskut Korea\t\t 30\t\t50pcs");
printf("\n4.cookies \t\tBiskut Kering\t\t 5\t\t50pcs");
printf("\n5.cake    \t\tKek Lapan Lapis\t\t 55\t\t1kg");
printf("\n6.cake    \t\tKek Ice Blended\t\t 89\t\t1kg");
printf("\n7.cake    \t\tKek Blueberry\t\t 100\t\t1kg");
printf("\n8.cake    \t\tKek Arab\t\t 120\t\t1kg");
printf("\n---------------------------------------------------------------------------");
}



void customer ()
// Customer Data
{
printf("\n\nCustomer Name : ");
scanf("%s", &name);
printf(" \nPhone No : ");
scanf("%s",&phone);
printf("  \nOrder Date : ");
scanf("%s",&ordate);
printf("\n---------------------------------------------------------------------------");

}



void choice ()
// Choice of menu Data
{
printf(" \nMenu Choice : (1-8)");
scanf("%d",&oder);

printf("\n\nYour choice is :");

if(oder==1)
{
printf(" Biskut Merry Ba");
printf("\n Order Quantity:");
scanf("%d",&quantity);
sum=a * quantity;
printf(" Total RM %.2f",sum);

}
else if(oder==2)
{
printf(" Biskut Tiger Go");
printf("\nOrder Quantity:");
scanf("%d",&quantity);
sum=b * quantity;
printf(" Total RM %.2f",sum);

}
else if(oder==3)
{
printf(" Biskut Korea");
printf("\nOrder Quantity:");
scanf("%d",&quantity);
sum=c * quantity;
printf(" Total RM %.2f",sum);

}
else if(oder==4)
{
printf(" Biskut Kering");
printf("\nOrder Quantity:");
scanf("%d",&quantity);
sum=d * quantity;
printf(" Total RM %.2f",sum);


}
else if(oder==5)
{
printf(" Kek Lapan Lapis");
printf("\nOrder Quantity:");
scanf("%d",&quantity);
sum=e * quantity;
printf(" Total RM %.2f",sum);

}
else if(oder==6)
{
printf(" Kek Ice Blended");
printf("\nOrder Quantity:");
scanf("%d",&quantity);
sum=f * quantity;
printf(" Total RM %.2f",sum);

}
else if(oder==7)
{
printf("Kek Blueberry");
printf("\nOrder Quantity:");
scanf("%d",&quantity);
sum=g * quantity;
printf(" Total RM %.2f",sum);

}
else if(oder==8)
{
printf("Kek Arab");
printf("\nOrder Quantity:");
scanf("%d",&quantity);
sum=h * quantity;
printf(" Total RM %.2f",sum);

}
else
{
printf("\n Please select again");
choice();
}
}



void receipt ()
// Receipts Data
{
clrscr();

printf("\n---------------------------------------------------------------------------");
printf("\n\t\t\t\tResepi Rahsio ");
printf("\n Customer Name \t:\t");
puts (name);
printf(" Phone No \t: \t%s", phone);
printf("\n Order Date \t: \t%s", ordate);
printf("\n Menu Choice \t:\t");

if(oder==1)
{printf("Biskut Merry Ba");}
else if(oder==2)
{printf("Biskut Tiger Go");}
else if(oder==3)
{printf("Biskut Korea");}
else if(oder==4)
{printf("Biskut Kering");}
else if(oder==5)
{printf("Kek Lapan Lapis");}
else if(oder==6)
{printf("Kek Ice Blended");}
else if(oder==7)
{printf("Kek Blueberry");}
else if(oder==8)
{printf("Kek Arab");}
else
{}
printf("\n Quantity \t: \t%d",quantity);
printf("\n Total \t\t: \tRM %.2f\n",sum);

if (sum>100)
{
printf("\nYour free cake is ");
if (freecake==1)
{printf("Kek Strawberi");}
else if (freecake==2)
{printf("Kek Pisang");}
else if (freecake==3)
{printf("Kek Durian");}
else if (freecake==4)
{printf("Kek Keledek");}
else
{printf("");}
}
else
{}
printf("\n---------------------------------------------------------------------------");
}



void free()
// Free gift Data
{
freecake=0;

printf("\n\n Congratulation, You got a free Cake");
freemenu();

printf("\n\n Select your free cake : ");
scanf("%d",&fcode);
switch (fcode)
{
case 100 :
printf("\n Free cake : Kek Strawberi\n");
chker='n';
freecake= 1;
break;

case 101 :
printf("\n Free cake : Kek Pisang\n");
chker='n';
freecake= 2;
break;

case 102 :
printf("\n Free cake : Kek Durian\n");
chker='n';
freecake= 3;
break;

case 103 :
printf("\n Free cake : Kek Keledek\n");
chker='n';
freecake=4;
break;

default:
printf("\n Please select again\n");
chker='y';
break;
}

receipt();
}



void bigbody()

// The BigBody data is made to resemble the full flow of event
{
clrscr();

char answ;

menu();
customer();
choice();

printf("\n\nDo you want to edit your order");
printf("\nYes = Y \nNo = N\n" );
scanf("%s", &answ);

switch (answ)
{
case 'y':
menu ();
choice();
break;
case 'n':
break;
default:
printf("Please choose again");
}

if (sum>100)
{free();}
else
{receipt();}

printf("\n\n\tThank you for your order \t\tPlease come again");

getch();

bigbody();
}




multilevel selection (else if with switch case)


#include <stdio.h>
#include <stdlib.h>

main()
{
      int answ,points;
      printf("enter char");
      scanf("%d",&answ);
     
      switch(answ)
     
      {
      case 'a' : points =4;
                   break;
      case 'b' : points =3;
                   break;
      case 'c' : points =2;
                   break;
      case 'd' : points =1;
                   break;
      case 'f' :
      case 'i' :
      case 'w' : points =0;
                   break;  
                 
      }
     
      if((answ >='a')&&(answ<='d'))
              printf("passed, points earned = %d",points);
      else
          printf("failed, no points earned");

      system("pause");
}

multilevel selection switch case


#include<stdio.h>
void main()
{
int number;
printf("Please enter your winning number");
scanf("%d",&number);
switch (number)
{
case 1: printf("Gold\n");
break;
case 2: printf("Silver\n");
break;
case 3: printf("Bronze\n");
break;
default: printf("Others");
}
}

else if with loop


#include<stdio.h>
main()
{
int age, i=0;
while (i<=20)
{
printf("Please enter your age\n\n");
scanf("%d",&age);


if((age >= 60))
printf("warga emas\n");
else if((age <= 59) && (age >= 25))
printf("Dewasa\n");
else if((age <= 24) && (age >= 12))
printf("Remaja\n");
else
printf("kanak kanak riang\n");

 i++;
}
}

without loop


#include<stdio.h>
main()
{

float weight, height, bmi_value;
char name[20];



printf("\nplease enter your name\n");
scanf("%s",&name);

printf("\nplease enter your weight\n");
scanf("%f",&weight);


printf("\nplease enter your height in meter\n");
scanf("%f",&height);

bmi_value = weight/(height*height);

printf("\nyour bmi value is  =  %.1f\n" ,bmi_value);


if((bmi_value >= 30.0))
printf("\nyour bmi status is obese\n");

else if((bmi_value <= 29.9) && (bmi_value >= 25.0))
printf("\nyour bmi status is overweight\n");

else if((bmi_value <= 24.9) && (bmi_value >= 18.5))
printf("\nyour bmi status is normal\n");

else
printf("\nyour bmi status is underweight\n");



}



Sunday, March 18, 2012

What is C Programming



What is C Programming?>??

  • Also known as software
  • List/sequence of instructions to computer
  • Consists of specific steps to be carried out by computer

   We can say that..Computer Programming is a series of instructions that tells a computer what to do and how to do it.

How its work??


    Instruct computer to do task or data processing
    to produce useful information.

That's the sample of c programming Code using Boorlan Turbo C++..



#include <stdio.h>//c proccessor
  

      int i,num;// int only use for integer value

main()//main body

{//program body
      
      
      printf("\n--------------------------------------------------------------------------------");//that's can be display a straight line
      printf("\n\n\t\t\t Create By     : Annonymous Hacker\n");//display name
      printf("\t\t\t Matric Number : SECRET007\n");//display matric num
      printf("\t\t\t Ic Number     : 851311-11-5510\n");//diplay ic num
      printf("\t\t\t Submit to     : sipolan bin sipolan\n");//display lecturer name 
      printf("\t\t\t Date          : 03/02/2012\n");//display date
      printf("\n--------------------------------------------------------------------------------");

      system("color 5E");//make a colour (5) is a background color and (E) is a font colour.. you can get a colour from the internet..
      
      printf("Enter the number which table is to be display : ");// ask user to add the number
      scanf("%d",&num);//read and display the num add by user.. %d is used to call int data type.&num is a int address that funtion to call num add by user.
      
      for(i=1; i<13; i++)//for...loop..i=13 and i start from 1.. so for..loop can repeat and display a data 12 times
      
      printf("\n%d * %d = %d",num,i,(num*i));//display a output result..
      
               
}//end of program body



Try this and learn something..enjoy this gracias...