Discuss in details how software (OS, editor, compiler, system library etc.) and computer hardware (CPU, memory, I/O devices and so on) interact when you create a new C program, and finally make an executable program and run it.
When the code in C is written using an editor, the code is first checked by the compiler and converted to a form close to machine language. Usually it is in the form of 0s and 1s.
The 0s and 1s are digital voltage given to the chip transistors. This voltage is used to run the hardware. The circuitry in the chip is connected by the voltage and operation of the program is performed.
Temporary data is stored inside the RAM and permanent data is stored on the disk.
An executable program in C to multiply two numbers:
#include<stdio.h> //header file
int main() //main function which returns value after finishing execution
{
int a,b,c; //3 integer variables are declared
scanf(%d %d", &a,&b); //run time value from the user is taken
c=a*b; //multiplying two integers using multiplication operator
printf("result is:",c); //result of multiplication is printed
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.