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
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