Q1.
#include
#include
void main()
{
clrscr();
printf("Hello Reader");
getch();
}
Q2.
#include
#include
void main()
{
int length=3, breadth=8;
int area = length*breadth;
printf("The area of this rectangle is %d", area);
getch();
}
Q3.
#include
#include
void main()
{
int length, breadth;
printf("What is the length of the rectangle\n");
scanf("%d", &length);
printf("What is the breadth of the rectangle\n");
scanf("%d", &breadth);
printf("The area of your rectangle is %d", length*breadth);
getch();
}
Q4.
#include
#include
void main()
{
int radius = 3;
float pi = 3.14;
printf("The area of this circle is %f\n", pi * radius * radius);
int height = 3;
printf("Volume of this cylinder is %f\n", pi * radius * radius * height);
getch();
}
Q5.
#include
#include
void main()
{
int a = 4;
float b = 8.5;
char c = 'u';
int d = 45;
int e = 45 + 4;
printf("The value of a is %d \n", a);
printf("The value of b is %f \n", b);
printf("The value of c is %c \n", c);
printf("Sum of a and d is %d \n", a - d);
printf("Sum of a and d is %d \n", e);
getch();
}
Q6.
#include
#include
void main()
{
int a, b;
printf("Enter a number\n");
scanf("%d", &a);
if(a%2==0){
printf("%d is even\n", a);
}
else{
printf("%d is odd\n", a);
}
getch();
}
Q7.
#include
#include
void main()
{
int age;
printf("Enter your age\n");
scanf("%d", &age);
if(age>90)
printf("You are above 90, you cannot drive\n");
else if(age<18)
printf("You are underage, you cannot drive\n");
else
printf("you can drive\n");
getch();
}
Q8.
#include
#include
void main()
{
int num;
printf("Enter your number\n");
scanf("%d", &num);
if(num==1)
{
printf("Your number is 1\n");
}
else if (num == 2)
{
printf("Your number is 2\n");
}
else if (num == 3)
{
printf("Your number is 3\n");
}
else
{
printf("Its not 1, 2 or 3!\n");
}
getch();
}
Q9.
#include
#include
void main()
{
float tax = 0, income;
printf("Enter your income\n");
scanf("%f", &income);
if(income>=250000 && income<=500000)
{
tax = tax + 0.05 * (income - 250000);
}
if (income >= 500000 && income <= 1000000)
{
tax = tax + 0.20 * (income - 500000);
}
if (income >= 1000000)
{
tax = tax + 0.30 * (income - 1000000);
}
printf("Your net income tax to be paid by 26th of this month is %f\n", tax);
getch();
}
Q10.
#include
#include
void main()
{
int a, b;
printf("Enter the value of a\n");
scanf("%d", &a);
printf("Enter the value of b\n");
scanf("%d", &b);
printf("The sum of a and b is %d", a + b);
getch();
}