Class 10 computer Book 2021 programming Exercise solution

Spread the love

Following is the solution of Class 10 computer Book 2021 programming Exercise solution of chapter No. 2. The programming Exercises solution is based on Class 10 computer Book 2021. The all exercises from chapter No. 2 are solved in Code Block C language programming Class 10 computer Book 2021 programming Exercise solution.

Class 10 computer Book 2021 programming Exercise solution

Code Block is the recommended IDE for Class 10 computer Book 2021 for programming in C language Class 10 computer Book 2021 programming Exercise solution. If you don’t have Code Block you can download it from the link.

Exercise No. 1 Solution

Write a program that should take working hours and overtime hours of employee as input. The program should calculate and display the total salary of employee. Class 10 computer Book 2021 programming Exercise solution

#include<stdio.h>
#include<conio.h>
int main()
{
int Basic_Salary, Overtime_Salary, Total_Salary, working_hours, overtime_hours;
printf("Please enter Working hours of Employee: ");
scanf("%d",&working_hours);
printf("Please enter Overtime hours of Employee: ");
scanf("%d",&overtime_hours);
Basic_Salary=working_hours*300;
Overtime_Salary=overtime_hours*400;
printf("\nTotal salary of Employee is: %dRS",Basic_Salary+Overtime_Salary);
getch();
}

Exercise No. 2 Solution

Write a program that takes Celsius temperature as input, converts the temperature into Fahrenheit and shows the output. Class 10 computer Book 2021 programming Exercise solution

#include<stdio.h>
#include<conio.h>
int main()
{
float celsius_temperature;
printf("Please enter Celsius Temperature: ");
scanf("%f",&celsius_temperature);
printf("\nThe Fahrenheit Temperature is: %f", 9.0/5 * celsius_temperature + 32);
getch();
} // Class 10 computer Book 2021 programming Exercise solution

Exercise No. 3 Solution

Write a program that displays the following output using single printf statement. Class 10 computer Book 2021 programming Exercise solution

  • Such as                 *             *             *             *
  • And                      1              2              3              4
#include<stdio.h>
#include<conio.h>
int main()
{
printf("*\t*\t*\t*\t\n1\t2\t3\t4");
getch();
}

Exercise No. 4 Solution

Write a program that displays the following output using single printf statement: I am a Boy I live in Pakistan I am a proud Pakistani

#include<stdio.h>
#include<conio.h>
int main()
{
printf("I am Boy\nI Live in Pakistan\nI am a proud Pakistani");
getch();
}

Exercise No. 5 Solution

A cloth brand offers 15% discount on each item. A lady buys 5 shirts from this brand. Write a program that calculates total price after discount and amount of discount availed by the lady. Original prices of the shirts are:

#include<stdio.h>
#include<conio.h>
int main()
{
int shirt1=423, shirt2=320, shirt3=270, shirt4=680, shirt5=520;
float TotalPrice, TotalDiscount, FinalPrice;
printf("First Shirt price: %d \t\tDiscount is %.2f \tPayable price: %.2f\n",shirt1, (shirt1*0.15), (shirt1-(shirt1*0.15)));
printf("Second Shirt price: %d \tDiscount is %.2f \tPayable price: %.2f\n",shirt2, (shirt2*0.15), (shirt2-(shirt2*0.15)));
printf("Third Shirt price: %d \t\tDiscount is %.2f \tPayable price: %.2f\n",shirt3, (shirt3*0.15), (shirt3-(shirt3*0.15)));
printf("Fourth Shirt price: %d \tDiscount is %.2f \tPayable price: %.2f\n",shirt4, (shirt4*0.15), (shirt4-(shirt4*0.15)));
printf("Fifth Shirt price: %d \t\tDiscount is %.2f \tPayable price: %.2f\n",shirt5, (shirt5*0.15), (shirt5-(shirt5*0.15)));
printf("\n\n-------------------------------------------------------------------------------------------------------------\n");
TotalPrice= shirt1 + shirt2 + shirt3 + shirt4 + shirt5;
TotalDiscount=(shirt1*0.15)+(shirt2*0.15)+(shirt3*0.15)+(shirt4*0.15)+(shirt5*0.15);
FinalPrice = (shirt1-(shirt1*0.15))+(shirt2-(shirt2*0.15))+(shirt3-(shirt3*0.15))+(shirt4-(shirt4*0.15))+(shirt5-(shirt5*0.15));
printf("Total price: %.2f \tTotal Discount is %.2f \tFinal price: %.2f\n",TotalPrice, TotalDiscount, FinalPrice);
getch();
}

Exercise No. 6 Solution

Write a program that swaps the value of two integer variables without help of any third variable.

#include<stdio.h>
#include<conio.h>
int main()
{
int a=10, b=20;
printf("Before swap a=%d b=%d",a,b);
a=a+b;   //a=30 (10+20)
b=a-b;   //b=10 (30-20)
a=a-b;   //a=20 (30-10)
printf("\nAfter swap a=%d b=%d",a,b);
getch();
}

Exercise No. 7 Solution

Write a program that takes a 5 digit number as input, calculates and displays the sum of first and last digit of number.

#include<stdio.h>
#include<conio.h>
int main()
{
int number;
printf("Enter a number with length 5 digits: ");
scanf("%d",&number);
printf("The sum of first and 5th digit is: %d", (number/10000)+(number%10));
getch();
}

Exercise No. 8 Solution

Write a program that takes monthly income and monthly expenses of the user like electricity bill, gas bill, food expense. Program should calculate the following.

#include<stdio.h>
#include<conio.h>
int main()
{
int monthly_income, electricity_bill, gas_bill, food_expense, monthly_Expenses, monthly_savings;
printf("Please enter your Monthly Income: ");
scanf("%d",&monthly_income);
printf("Please enter you Monthly Expenses: ");
printf("\n\n\tYour Electricity Bill: ");
scanf("%d",&electricity_bill);
printf("\tYour Gas Bill: ");
scanf("%d",&gas_bill);
printf("\tYour Food Expense: ");
scanf("%d",&food_expense);
monthly_Expenses=electricity_bill+gas_bill+food_expense;
printf("\n\n\tTotal Monthly Expenses are: %d", monthly_Expenses);
printf("\n\tTotal Yearly Expenses are: %d", (monthly_Expenses)*12);
monthly_savings =monthly_income-monthly_Expenses;
printf("\n\n\tYour Monthly savings is: %d", monthly_savings);
printf("\n\tYour Monthly savings is: %d", monthly_savings*12);
printf("\n\n\tAverage saving per month: %d", monthly_savings);
printf("\n\tAverage expense per month: %d", monthly_Expenses);
getch();
}

Exercise No. 9 Solution

Write a program that takes a character and number of steps as input from user. Program should then jump number of steps from that character.

#include<stdio.h>
#include<conio.h>
int main()
{
char c;
int steps;
printf("Enter character: ");
scanf("%c",&c);
printf("Enter Steps: ");
scanf("%d",&steps);
int x = c + steps;
printf("New Character: %c",x);
getch();
}

Exercise No. 10 Solution

Write a program that takes radius of a circle as input. The program should calculate and display the area of circle.

#include<stdio.h>
#include<conio.h>
int main()
{
float radius;
printf("Please enter the radius of circle: ");
scanf("%f",&radius);
printf("\nArea of circle is: %.2f", 3.14*radius*radius);
getch();
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *


*