Embedded C Lab
Embedded C Lab
LAB ASSESSMENT 1
Experiment – 1
Basic
1 – 4000 4001 – 8000 8001 – 12000 12000 above
Example:
If the basic salary is 45000,
then the gross salary = 45000 + 45000 x 0.3 + 45000 x 0.8 = 94500.00
Code:
#include <stdio.h>
int main() {
float basic_salary, gross_salary, da, hra;
return 0;
}
Q2) An electricity board charges the following rates for use of electricity For the first 200
units: Rs 1 per unit
For the next 100 units: Rs. 1.5 per unit
For the above 300 units: Rs. 2 per unit
Write a C program to read no of units consumed and printout total charge amount.
Code
#include <stdio.h>
int main() {
int units;
float total_charge = 0;
return 0;
}
Q3) Write a C program which will print two digit numbers whose sum of both digits is
multiple of seven
Code
#include <stdio.h>
int main() {
int tens_digit, ones_digit;
return 0;
}
Q4)
Code
#include <stdio.h>
int main() {
int income, tax = 0;
return 0;
}
Q5) A number is called an Armstrong number if the sum of the cubes of the digits of the
number is equal to the number. Write a C program that asks the user to enter a number and
returns if it is Armstrong or not
Example:
If the input number is 153,
#include <stdio.h>
originalNum = num;
while (originalNum != 0) {
remainder = originalNum % 10;
result += remainder * remainder * remainder;
originalNum /= 10;
}
if (result == num) {
return 1; // True, number is Armstrong
} else {
return 0; // False, number is not Armstrong
}
}
int main() {
int num;
if (isArmstrong(num)) {
prin?("%d is an Armstrong number.\n", num);
} else {
prin?("%d is not an Armstrong number.\n", num);
}
return 0;
}