Question

Describe why you might want to write a script vs. a C program. Describe two example...

  1. Describe why you might want to write a script vs. a C program. Describe two example situations that illustrate your answer, one each for script and C.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

In context of programming,There are 3 types of translators.

1)Interpreter

2)Compiler

3)assembler

The explanation can be given with the help of following example:

script is translated by interpreter, for example, in a web page java script is translated by the interpreter,

and this interpreter is available on web browser.

java script is executed on client side.

if there is a need to write a logic, which is to be executed on web page(on client side).then C program can not work.

java script will be used to write a logic, which is to be executed on web page(on client side).

following code is a combination of java script and HTML,which is being used to determine whether a number is EVEN or ODD,

on web page(on client side).

the code given below will be translated by the interpreter.

code

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript">
function test()
{  
   var a=prompt("Enter a no.");
   if(a%2==0)
   {
       document.write("<body bgcolor='yellow'>");
       document.write("<h1>Even Number</h1>");
   }
   else
   {
       document.write("<body bgcolor='gray'>");
       document.write("<h1>Odd Number</h1>");
   }
}
</script>
</HEAD>
<BODY onLoad="test()">
</BODY>
</HTML>

if the same login is required on local computer's console the C program should be used, and source code will be compiled.

C code to determine whether a number is EVEN or ODD

#include<stdio.h>
int main()
{int num;
   printf("Enter a number");
   scanf("%d",&num);
   if (num%2==0)
   {
       printf("\n Number is EVEN");
      
   }
   else
   {
           printf("\n Number is Odd");
   }
return 0;  
}

Example 2

JavaScript provides a library "Pebble JS".

Now a days this library is being used in smartwatch applications.

Example 3:

Node JS can also be used to program flying Robots.

Application Area of C

1) Operating System:- There is C programming behind UNIX operating system .

2) High speed:- C can be used where high speed of execution is required.

3) Embedded System:- C is being used in Embedded systems.

Summary

script is translated by the interpreter.

java script is used to produce output on web browser

C program is translated by the compiler .

C program is used to produce output on local Computer's console.

Java script should be used for web pages/ mobile devices.

C should be used where high speed of execution is  required.

script is translated by interpreter

C program is translated by compiler.

interpreter translates line by line.

Compiler translate entire code in a single attempt and reports all the errors(if any) in a single attempt

Add a comment
Know the answer?
Add Answer to:
Describe why you might want to write a script vs. a C program. Describe two example...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program to simulate deposit/withdraw activities on a banking account. (Hint: you might want...

    Write a C program to simulate deposit/withdraw activities on a banking account. (Hint: you might want to review Lab 3 slides.) (25 points)  Declare the balance as a global variable and initialize it to 600.  Write two functions, one for withdraw, the other for deposit. Both withdraw and deposit functions have one parameter, which represent the amount to withdraw or deposit. The functions deduct the balance and add to the balance one dollar at a time, respectively. Therefore,...

  • Write a program in C or a script in bash, called “compare” that takes two numbers on the command line and compares them....

    Write a program in C or a script in bash, called “compare” that takes two numbers on the command line and compares them. The program should print the result of the comparison. Specifically, it should print “<x> is <comparison> <y>”, where <x> is the first number, <y> is the second number and <comparison> is one of “equal to”, “greater than” or “less than”. If the two numbers are equal, the program should have an exit status of zero. The exit...

  • Programming Exercise 4.9 Write a script named numberlines.py. This script creates a program listing from a...

    Programming Exercise 4.9 Write a script named numberlines.py. This script creates a program listing from a source program. This script should: Prompt the user for the names of two files. The input filename could be the name of the script itself, but be careful to use a different output filename! The script copies the lines of text from the input file to the output file, numbering each line as it goes. The line numbers should be right-justified in 4 columns,...

  • In VS if you can please!! Multiplication write a program that executes the multiplication of two...

    In VS if you can please!! Multiplication write a program that executes the multiplication of two numbers entered by the user using only the addition operation. For example, if the user enters 3 and 4, the program computes the multiplication of these numbers by adding the number 4 three times (i.e., 3 * 4 = 4 + 4 + 4). Solve this problem in the most efficient way.

  • You are currently running/debugging a shell script program in the foreground that seems to be in an infinite loop, to terminate/kill the shell script program. 7. (type/enter - control C to send a &#3...

    You are currently running/debugging a shell script program in the foreground that seems to be in an infinite loop, to terminate/kill the shell script program. 7. (type/enter - control C to send a "program interrupt" ) or (contact the sysadmin person to kill your shell script program) 8. The UNIX/Linux exit command entered on the KORN shell command line will exit the shell session properly (best practice). [True / False] When killing a background process with the kill command you...

  • Why are arrays important? Can you describe a situation during the design of a script where...

    Why are arrays important? Can you describe a situation during the design of a script where an array can be helpful? When would arrays be more appropriate to use than a database? What situations would a database be more appropriate to use than an array? Do arrays have any advantages over using a database?

  • Please write a bash script for the following two questions, thank you.    Write a shell script...

    Please write a bash script for the following two questions, thank you.    Write a shell script “6-1.sh” to calculate the exponentiation using while loop. This script needs to take two inputs like “6-1.sh a b”, and outputs the result of “ab”. Note: You need to implement it, DO NOT use the exponentiation operation provided by the Linux.    Write a shell script “6-2.sh” to calculate the factorial of a number using while loop. This script needs to take one input...

  • Parallelogram Program Write a program that prints the following parallelogram pattern given the the following two...

    Parallelogram Program Write a program that prints the following parallelogram pattern given the the following two inputs. Here are the rules: Your program must work with any length greater than 1. Your program must use the character the user inputs to draw the parallelogram. Your program must not use global variables or global code other than a call to main(). Your program output must match my out exactly. I have provided you with the strings you need for the output...

  • 4-6 on matlab 4. Write a program in a script file that determines the real roots...

    4-6 on matlab 4. Write a program in a script file that determines the real roots of a quadratic equation ax2+bx+c 0 When the file runs, it asks the user to enter the values of the constants a, b, and c. To calculate the roots of the equation the program calculates the discriminant D, given by: D b2-4ac When D 0, the program displays message "The equation has two roots," and the roots are displayed in the next line. When...

  • Step 3: How would you write this script in C? It needs to do the things...

    Step 3: How would you write this script in C? It needs to do the things required in step 3. 1. You have received a new batch of distinguished users; their basic information is located in newusers.tar. Inside of the tar file, there is a file called "newusers.txt" which contains a colon-separated entry for each user: the username, the uid, the GECOS information, and the user's preferred shell. Also in the tar file you will find a public key for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT