What is a Scripting Language?

A scripting language is a programming language that is interpreted. It is translated into machine code when the code is run, rather than beforehand. Scripting languages are often used for short scripts over…

Read more

Example: Check Prime and Armstrong #include <math.h> #include <stdio.h> int checkPrimeNumber(int n); int checkArmstrongNumber(int n); int main() { int n, flag; printf(“Enter a positive integer: “); scanf(“%d”, &n); // check prime number flag…

Read more

Reverse a sentence using recursion

#include <stdio.h> void reverseSentence(); int main() { printf(“Enter a sentence: “); reverseSentence(); return 0; } void reverseSentence() { char c; scanf(“%c”, &c); if (c != ‘\n’) { reverseSentence(); printf(“%c”, c); } } Output…

Read more

Program to convert binary to decimal

#include <math.h> #include <stdio.h> int convert(long long n); int main() { long long n; printf(“Enter a binary number: “); scanf(“%lld”, &n); printf(“%lld in binary = %d in decimal”, n, convert(n)); return 0; }…

Read more

GCD of Two Numbers using Recursion

#include <stdio.h> int hcf(int n1, int n2); int main() { int n1, n2; printf(“Enter two positive integers: “); scanf(“%d %d”, &n1, &n2); printf(“G.C.D of %d and %d is %d.”, n1, n2, hcf(n1, n2));…

Read more

Program to calculate power using recursion

#include <stdio.h> int power(int n1, int n2); int main() { int base, a, result; printf(“Enter base number: “); scanf(“%d”, &base); printf(“Enter power number(positive integer): “); scanf(“%d”, &a); result = power(base, a); printf(“%d^%d =…

Read more

Power of a Number Using the while Loop

The program below takes two integers from the user (a base number and an exponent) and calculates the power. For example: In the case of 23 2 is the base number 3 is…

Read more

Power of a Number Using the while Loop

#include <stdio.h> int main() { int base, exp; long double result = 1.0; printf(“Enter a base number: “); scanf(“%d”, &base); printf(“Enter an exponent: “); scanf(“%d”, &exp); while (exp != 0) { result *=…

Read more

Reverse an Integer

#include <stdio.h> int main() { int n, rev = 0, remainder; printf(“Enter an integer: “); scanf(“%d”, &n); while (n != 0) { remainder = n % 10; rev = rev * 10 +…

Read more

Simple Calculator using switch Statement

#include <stdio.h> int main() { char op; double first, second; printf(“Enter an operator (+, -, *, /): “); scanf(“%c”, &op); printf(“Enter two operands: “); scanf(“%lf %lf”, &first, &second); switch (op) { case ‘+’:…

Read more