JS Code-Count Pizza-order!!

The following code is to count the total cost of pizzas ordered. Just a slight bit of logic and assumed costs and taxes.

var orderCount=0;
var getSubTotal=function (itemCount){
return(itemCount*7.5);
}
var getTax= function(){

return getSubTotal(orderCount)* 0.06;
}

var getTotal= function(){
return(getTax()+getSubTotal(orderCount));
}
var takeOrder=function(topping,crustType)
{
console.log(“Order:”+ crustType +” pizza topped with -“+ topping);
orderCount++;
}
takeOrder(“bacon”,”thin”);
takeOrder(“veg”,”thick”);
takeOrder(“corn”,”cheesy”);
console.log(getSubTotal(orderCount));
console.log(getTotal());

JS Code- Make a game!!

The following code is just a starter tip only to know what the basic kowledge of javascript can provide. So if you are a begginer, don’t worry and go through the following code and see how much you can understand this program.

Enjoy coding……

/*Rock-Paper-Scissors game in Javascript*/

/*Using math.random function to get computer’s choice. and Prompt for taking user’s input.*/

var userChoice = prompt(“Do you choose rock, paper or scissors?”);
var computerChoice = Math.random();

/*There are three choices so the random choice is made in three parts out of 1 as: 0-0.34 , 0.34-0.67 and 0.67-1. The computer choice will depend on these three.*/

if (computerChoice < 0.34)  

{
computerChoice = “rock”;
}

else if(computerChoice <= 0.67) {
computerChoice = “paper”;
}

else {
computerChoice = “scissors”;
}

console.log(“Computer: ” + computerChoice);

var compare= function(choice1,choice2){
if(choice1 === choice2){
return(“The result is a tie!”);
}
else if(choice1 === “rock”)  /*when user’s choice is a rock*/
{
if(choice2 === “scissors”){
return(“rock wins”);
}
else{
return(“paper wins”);
}
}
else if(choice1 === “paper”)  /*when user’s choice is a paper*/
{
if(choice2 === “rock”){
return(” paper wins”);
}
else{
return(“scissors wins”);
}

}
else if(choice1===”scissors”)  /*when user’s choice is  scissors*/

{
if(choice2 === “rock”){
return(” rock wins”);
}
else{
return(“scissors wins”);
}
}
else if(choice1===”rope”)  /*when user’s choice is something else like rope*/

{
if(choice2===”rock”){
return(“rope wins”);
}
else if(choice2===”paper”){
return(“rope wins”);
}
else
{
return(“scissors wins”);
}
}
else{
choice1= prompt(” inappropriate input, make new choice…”);
}
}
compare (userChoice,computerChoice); /*calling the compare function*/

C language- first program….

The very first program we are used to see in every language is- the hello world program. so keeping it like that, let us look at the very basic code of the very basic langusge itself.

PROGRAM:-

/*Writes the words "Hello World" on the screen */
  
#include<stdio.h>

int main()
{
    /* first C program */
    printf("Hello World!!\n");
    getch(); //Use to get one character input from user, and it will not be printed on screen.
    return 0;
}

Output:-

Hello World!!

Let’s Code Together…………….

From your Watch to the house you live in, everything in twenty-first century today is programmed. this makes a curiosity to know the amazing texts and languages which make these system alive. so here we are!! the site will make you get started from the very basic programs like for eg: hello world to as complex as it can. with every post the level and features of the language will increase and this will prove more fun if i can get the audience’s reviews and queries and requests for any program.

Why I made this site?? well, I love to learn new things and this site is for the same to learn!! I find the way of blogging on the language and answering be the best way to keeping up the learning thing. So lets start our adventure to teach and learn ,both at the same time. i hope it will help all beginners and i could reach my said goal too.

My goal is to make this site, a collection of all possible programs and code we can think of in our daily lives and professional. this can happen not only by mine but your participation and help. lets see how far we can go……………………..