Program:
#include<stdio.h>
#include<math.h>
void main()
{
float P,rate,r,r1,n,years,mp,power;
prin ("Total loan Amount:$");
scanf("%f",&P);
prin ("Annual Interest Rate:");
scanf("%f",&rate);
prin ("Number of years for Repayment:");
scanf("%f",&years);
rate=rate/100;
r=rate/12;
r1=r+1;
n=years*12;
power=pow(r1,n);
mp=(P*r*power)/(power-1);
prin ("Monthly Payment:$ %f",mp);
}
Program:
/*Implement an access control system for a building where different levels of
* permissions are stored in a single integer (bitwise flags). For example:
* Bit 0: Access to main gate
* Bit 1: Access to cafeteria
* Bit 2: Access to IT department
* Bit 3: Access to the server room
* Write a program to:
* A. Grant a specific access based on user input
* B. Check if a user has access to a certain facility.
*/
//libraries
#include<stdio.h>
#include<math.h>
//Declaring Variables
int chk,user,grant,a;
//Program
void main(){
//input
prin ("Enter the facility number to grant access(0: Main gate, 1: Cafeteria, 2: IT dept, 3: Server
room): \n");
scanf("%d",&grant);
//bitwise or
user = user | (1 << grant);
prin ("Access Control Updated:%d\n",user);
prin ("Check Access:\n");
scanf("%d",&chk);
//bitwise and
a = ((user&(1<<chk))?prin ("User has Access"):prin ("User doesn\'t have access"));