AD Blocker Detected

Ads can be a pain, but they are our only way to maintain the server. Please deactive Ads blocker to read the content. Your co-operation is highly appreciated and we hope our service can be worth it.

Write a program to display “hello world” in C.

#include <stdio.h>
int main(){
    printf("Hello World");
    return 0;
}

Write a program to add two numbers (5&7) and display its sum.

#include <stdio.h>

int main(){
    int a=5,b=7,sum;
    sum =a+b;
    printf("\nSum of two numbers:%d\n",sum);
    return 0;
}

Write a program to multiply two numbers (10&8) and display its product.

#include <stdio.h>

int main(){
    int a=10,b=8,product;
    product = a*b;
    printf("\nProduct of two numbers is %d",product);
    return 0;
}

Write a program to calculate the area of a circle having its radius (r=5).

#include <stdio.h>
#define PI 3.14

int main(){
    int radius=5;
    float area;
    area=PI*radius*radius;
    printf("\nArea of circle is %f",area);
    return 0;
}

Write a program to calculate the area of an ellipse having its axes (minor=4cm, major=6cm).

#include <stdio.h>
#define PI 3.14

int main(){
    int minor=4,major=6;
    float area;
    area = PI*minor*major;
    printf("Area of an ellipse is %f",area);
    return 0;
}

Write a program to calculate simple interest for a given P=4000, T=2, R=5.5.

#include <stdio.h>

int main(){
    int principal = 4000,time=2;
    float simple_interest,rate=5.5;
    simple_interest = (principal*time*rate)/100;
    printf("Simple Interest is %f",simple_interest);
    return 0;
}

Keep sharing

If you have question ,lab assignments . contact to me. I will post.

C
Similar Posts