You are on page 1of 14

Task01

#include<stdio.h>

#include<stdio.h>

int main()

float a, b, c, sum, average;

printf("Enter the 1st number : ");

scanf("%f", &a);

printf("Enter the 2nd number : ");

scanf("%f", &b);

printf("Enter the 3rd number : ");

scanf("%f", &c);

sum = a + b + c;

average = sum / 3;

printf("Sum: %.2lf\n", sum);

printf("Average: %.3lf\n", average);

return 0;

}
Task02

#include<stdio.h>

#include<stdio.h>

int main() {

float x, area;

printf("Enter the value of x : ");

scanf("%f", &x);

area = x * x;

printf("The area of a Square is : %.3f\n", area);

return 0;

}
Task03

#include<stdio.h>

int main() {

float x, perimeter;

printf("Enter the value of x : ");

scanf("%f", &x);

perimeter = 4 * x;

printf("The primeter of a square is : %0.3f\n", perimeter);

return 0;

}
Task04

#include<stdio.h>

#include<math.h>

int main() {

double base, power, solution;

printf("Enter base value : ");

scanf("%lf", &base);

printf("Enter power value : ");

scanf("%lf", &power);

solution = pow(base, power);

printf("Solution is : %0.2lf\n", solution);

return 0;

}
Task05

#include<stdio.h>

int main() {

float radius, circumference;

printf("Enter radius value : ");

scanf("%f", &radius);

circumference = 2 * 3.1416 * radius;

printf("The circumference of a circle is : %.3f\n", circumference);

return 0;

}
Task06

#include <stdio.h>

#include <stdlib.h>

int main() {

int dividend, divisor, quotient, remainder;

printf("Enter dividend value: ");

scanf("%d", &dividend);

printf("Enter divisor value: ");

scanf("%d", &divisor);

quotient = dividend / divisor;

remainder = dividend % divisor;

printf("Quotient = %d\n", quotient);

printf("Remainder = %d", remainder);

return 0;

}
Task07

#include <stdio.h>

#include <stdlib.h>

int main() {

printf("######\n");

printf("#\n");

printf("#\n");

printf("#####\n");

printf("#\n");

printf("#\n");

printf("\n\n");

printf(" ######\n");

printf(" ## ##\n");

printf("#\n");

printf("#\n");

printf("#\n");

printf("#\n");

printf("#\n");

printf(" ## ##\n");

printf(" ######\n");

return 0;

}
Task08

#include <stdio.h>

#include <stdlib.h>

int main() {

int Num_of_days, days, weeks, years;

printf("Enter total number of days : ");

scanf("%d", &Num_of_days);

years = Num_of_days / 365;

weeks = (Num_of_days % 365) / 7;

days = Num_of_days - ((years * 365) + (weeks * 7));

printf("Years : %d\n", years);

printf("Weeks : %d\n", weeks);

printf("Days : %d\n", days);

return 0;

}
Task09

#include <stdio.h>

#include <stdlib.h>

int main() {

float distance, fuel_spent, Average_consumption;

printf("Enter total distance in km : ");

scanf("%f", &distance);

printf("Enter total fuel spent in liters : ");

scanf("%f", &fuel_spent);

Average_consumption = distance / fuel_spent;

printf("Average consumption (km/lt) : %.2f\n",

Average_consumption);

return 0;

}
Task10

#include <stdio.h>

#include <stdlib.h>

int main() {

float x1, y1, x2, y2, distance;

printf("Input x1 : ");

scanf("%f", &x1);

printf("Input y1 : ");

scanf("%f", &y1);

printf("Input x2 : ");

scanf("%f", &x2);

printf("Input y2 : ");

scanf("%f", &y2);

distance = ((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1));

printf("Distance between the said points : %.4f\n", sqrt(distance));

return 0;

}
Task11

#include <stdio.h>

#include <stdlib.h>

int main() {

char id[10];

int hour;

double value, salary;

printf("Input the Employees ID(Max. 10 chars): ");

scanf("%s", &id);

printf("Input the working hrs: ");

scanf("%d", &hour);

printf("Salary amount/hr: ");

scanf("%lf", &value);

salary = value * hour;

printf("Employees ID = %s\nSalary = U$ %.2lf\n", id, salary);

return 0;

}
Task12

#include <stdio.h>

#include <stdlib.h>

int main() {

float x, y;

printf("Enter the value of x : ");

scanf("%f", &x);

printf("Enter the value of y : ");

scanf("%f", &y);

if(x < y) {

printf("%.2f is smaller than %.2f", x, y);

} else {

printf("%.2f is smaller than %.2f", y, x);

return 0;

}
Task13

#include <stdio.h>

#include <stdlib.h>

int main() {

float X, Y;

printf("Enter the value of X : ");

scanf("%f", &X);

printf("Enter the value of Y : ");

scanf("%f", &Y);

if(X > Y) {

printf("%.2f is greater than %.2f", X, Y);

} else {

printf("%.2f is greater than %.2f", Y, X);

return 0;

You might also like