top of page
Code Craze - Jan 22, 2023
- 1 min read
C is a high-level programming language that was developed in the early 1970s by Dennis Ritchie at Bell Labs. It is a general-purpose, procedural, and imperative programming language that is widely used for developing operating systems, embedded systems, and other applications that require low-level access to hardware.
One of the key features of C is its ability to provide low-level access to memory and hardware resources, which makes it a popular choice for developing systems and applications that need to perform complex and time-critical tasks. It also provides a high degree of control over the hardware, making it a suitable choice for developing operating systems and embedded systems.
C is a compiled language, which means that the source code is translated into machine code by a compiler before it can be executed. This allows for faster execution times compared to interpreted languages.
C is also a popular choice for developing system software and applications for a wide range of platforms, including Windows, Linux, and macOS, as well as embedded systems, such as microcontrollers and mobile devices.
C is a powerful and versatile language that is widely used in industry and academia. However, it can be difficult to learn and use effectively, as it does not provide many of the high-level abstractions and automatic memory management features found in modern languages.
1 view0 comments
Code Craze - Jan 22, 2023
- 1 min read
Updated: Jan 22, 2023
#include <stdio.h>
void main() {
int num1, num2, mod;
printf("Enter the first number: ");
scanf("%d", &num1); // Read the first number from the user
printf("Enter the second number: ");
scanf("%d", &num2); // Read the second number from the user
mod = num1 % num2; // Calculate the mod
printf("The modulus of %d and %d is %d\n", num1, num2, mod); // Print the result}
Here's a brief explanation of the code:
The first line #include <stdio.h> is a preprocessor directive that tells the compiler to include the standard input/output library. This library contains functions like printf and scanf that are used to read input and print output.
int main() is the main function where the program starts executing.
int num1, num2, mod; declares three variables: num1 and num2 to store the two numbers and mod to store the result.
printf("Enter the first number: "); prints the message "Enter the first number: " on the screen, asking the user to enter the first number.
scanf("%d", &num1); reads an integer from the user and stores it in the variable num1. The & operator is used to pass the address of the variable to the function, so that it can store the input in that location.
The same steps are repeated for the second number.
mod = num1 % num2; calculates the modulus of num1 and num2 and stores it in the variable mod.
printf("The modulus of %d and %d is %d\n", num1, num2, mod); prints the result on the screen. The %d is a placeholder for an integer.
You can run this program on a C compiler.
3 views0 comments
bottom of page