C Code Examples: Calculator, Leap Year, and More

C Code Examples

1. Calculator


#include <stdio.h>

int main() {
    char operator;
    double num1, num2, result;

    // Input
    printf("Enter an operator (+, -, *, /): ");
    scanf(" %c", &operator);

    printf("Enter two numbers: ");
    scanf("%lf %lf", &num1, &num2);

    // Switch case to perform calculation based on the operator
    switch (operator) {
        case '+':
            result = num1 + num2;
            break;
        case '-':
            result = num1 - 
Read More

C Code Examples: Triangle, Commission, Date, Search

Triangle Type Determination

This C code determines the type of triangle based on the lengths of its sides.

#include <stdio.h>

// Function to check if sides form a triangle
int isValidTriangle(int a, int b, int c) {
    return (a + b > c) && (a + c > b) && (b + c > a);
}

// Function to determine the type of triangle
void determineTriangleType(int a, int b, int c) {
    if (!isValidTriangle(a, b, c)) {
        printf("Not a triangle.\n");
        return;
    }
    if 
Read More

Adding a Custom Service in Android System

This document describes how to add a custom service to the Android system. This example was implemented on Android 7.0, so code locations may vary on different systems.

1. Design the Interface

Create a new folder named addservice under the frameworks/base directory. Inside addservice, create the following structure:

  • Android.mk
  • java/android/mymodule/test (This path can be customized)

The java/android/mymodule/test directory will contain the Java interface files and corresponding AIDL files.

The Android.

Read More

Martin Luther King, Jr.: Life, Speeches, and Legacy

Martin Luther King, Jr.

Name: Martin Luther King, Jr.

Date of Birth: Noon, Tuesday, January 15, 1929

Place of Birth: At the family home, 501 Auburn Avenue, N.E., Atlanta, Georgia

Date of Death: April 4, 1968

Education

Martin Luther King, Jr. began his education at the Yonge Street Elementary School in Atlanta, Georgia. Following Yonge School, he was enrolled in David T. Howard Elementary School. He also attended the Atlanta University Laboratory School and Booker T. Washington High School. Because of

Read More

Martin Luther King, Jr.’s 1963 Speech: A Call for Racial Equality

**”I Have a Dream”**

Along with Abraham Lincoln’s Gettysburg Address, delivered one hundred years earlier, Martin Luther King, Jr.’s “I Have a Dream” speech is one of the most memorable in U.S. history. It was delivered on the steps of the Lincoln Memorial in Washington, D.C., on August 28, 1963, where nearly a quarter of a million people gathered for a March for Jobs and Freedom to urge Congress and President John F. Kennedy to pass a national civil rights bill.

The Civil Rights Movement

Read More

Mobile Telephony: Cellular Systems, GSM, and Roaming

Mobile Telephony

What is a Cell System?

A cell system consists of dividing the service area into cells, each containing a radio station that restricts its coverage area.

Elements of a Cellular System

  • Mobile Stations (MS)
  • Base Stations (BS)
  • Mobile Switching Center (MSC)
  • Public Switched Telephone Network (PSTN)

Understanding Hand-Over and Hand-Off

These are the necessary changes to keep communication channels uninterrupted when moving from one cell to another.

Technical Characteristics of the GSM System

  • Frequency
Read More