Skip to main content

Q1. Print Your Name

Write a C program that prints your name.
#include <stdio.h>

int main() {
    printf("John Doe\n");
    return 0;
}

Q2. Area of a Rectangle

Take length and breadth as input and print the area.
#include <stdio.h>

int main() {
    float length, breadth;
    printf("Enter length and breadth: ");
    scanf("%f %f", &length, &breadth);
    printf("Area = %.2f\n", length * breadth);
    return 0;
}

Q3. Swap Two Numbers

Swap two integers without using a third variable.
#include <stdio.h>

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    a = a + b;
    b = a - b;
    a = a - b;
    printf("a = %d, b = %d\n", a, b);
    return 0;
}