C PROGRAM ASS-1
C PROGRAM ASS-1
PROGRAMMING IN C -CS3251
NAME:PAVITHRA J
REG NO:715524104107
CLASS :CSE-B
____________________________________________________
Q.NO:1
Babu wants to design software to calculate the Electricity bill. He needs to calculate the final amount
based on meter reading. Help babu to calculate the electricity bill based on the initial and final meter
reading.
Input Format
Constraints
Output Format
Total amount
Sample Input 0
400
1200
Sample Output 0
Rs. 3760.00
Sample Input 1
1200
1100
Sample Output 1
Invalid Input
SOLUTION:
#include <stdio.h>
int main()
int initial_reading,final_reading,units,fixed_charge;
float cost,total;
scanf("%d",&initial_reading);
scanf("\n%d",&final_reading);
units=final_reading-initial_reading;
if(initial_reading<=final_reading)
if(units<=100)
{
fixed_charge=0;
cost=0;
else if(units<=200)
fixed_charge=20;
cost=(units-100)*2.0;
else if(units<=500)
fixed_charge=30;
cost=(100*2.0)+((units-200)*3.0);
else
fixed_charge=50;
cost=(100*3.5)+(300*4.6)+((units-500)*6.6);
total=fixed_charge+cost;
printf("Rs. %.2f",total);
else
{
printf("Invalid Input");
return 0;
LEADER BOARD:
Q.NO:2
Tim and Bob are off to a famous Education Fair "Knowledge Forum 2022" at Chennai.
This time they have to travel without their guardians. Tim got very interested in the
arrangement of seats inside the train coach.
Tim and Bob are playing this game of finding the co-partner in train of each berth. Write
a program to do the same.
Input Format
The input consists of an integer N, which corresponds to the berth number whose
neighbor is to be found out.
Constraints
-
Output Format
The output is to display the berth of the neighbor of the corresponding seat. Refer
sample input and output for formatting specifications.
Sample Input 0
Sample Output 0
4LB
Sample Input 1
Sample Output 1
2MB
SOLUTION;
#include <stdio.h>
void my_co_pa(int a) {
char *seat[] = {"LB", "MB", "UB", "LB", "MB", "UB", "SL", "SU"};
int pos = (a - 1) % 8;
int main() {
int a;
scanf("%d", &a);
my_co_pa(a);
return 0;
LEADER BOARD:
Q.NO:3
Joseph recently joined a nationalized bank. His daily task is to give the amount to
customers. He wants to find the minimum number of notes/coins required for the given
amount. Write a program to input the amount from the user and print the minimum
number of notes and coins (Rs.2000, Rs. 500, Rs.200, Rs.100, Rs.50, Rs.20, Rs.10,
Rs5, Rs.2, Rs.1) required for the amount.
Input Format
Amount in firstline
Constraints
Output Format
Sample Input 0
2888
Sample Output 0
Denomination
2000 = 1
500 = 1
200 = 1
100 = 1
50 = 1
20 = 1
10 = 1
5=1
2=1
1=1
Sample Input 1
159
Sample Output 1
Denomination
2000 = 0
500 = 0
200 = 0
100 = 1
50 = 1
20 = 0
10 = 0
5=1
2=2
1=0
SOLUTION:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int amount;
scanf("%d",&amount);
int denominations[]={2000,500,200,100,50,20,10,5,2,1};
int count[10]={0};
printf("Denomination\n");
amount%=denominations[i];
printf("%d = %d\n",denominations[i],count[i]);
return 0;
LEADER BOARD: