Professional Documents
Culture Documents
Lab 03 Assignment No - 03
Lab 03 Assignment No - 03
Lab 03 Assignment No - 03
Creative Technology
(SMUCT)
Assignment
Submitted By:
Name: Md Jubaer
ID No: 241071051
Batch: 34th
Section: B
Program: B.sc Eng. in CSE
LAB-03
Task-1
Write a program to enter a 4 digits number from the keyboard. Add 8 to the
number and then divide it by 3. Now, the modulus of that number is taken with 5
and then multiply the resultant value by 5. Display the final result.
#include <stdio.h>
//Md.Jubaer
//ID-241071051
int main() {
int number;
float result;
number += 8;
result = (float)number / 3;
result = (int)result % 5;
result *= 5;
return 0;
}
Task-2
Enter two numbers from the keyboard. Write a program to check if the two
numbers are equal.
#include <stdio.h>
#include <stdlib.h>
//Jubaer
//ID-241071051
int main() {
int A, B;
if (A == B)
{
printf("The two numbers are equal.\n");
}
else
{
printf("The two numbers are not equal.\n");
}
return 0;
}
Task-3
Write a program to enter the values of two variables ‘a’ and ‘b’ from the
keyboard and then
check if both the conditions ‘a<50’ and ‘a<b’ are true.
#include <stdio.h>
int main() {
int a, b;
return 0;
}
Task-4
Now solve the above question to check if at least one of the conditions
‘a<50’ and ‘a<b’ is true.
#include <stdio.h>
int main() {
int a, b;
if (a < 50 || a < b) {
printf("At least one of the conditions 'a < 50' and 'a < b' is true.\n");
} else {
printf("Both conditions are false.\n");
}
return 0;
}
Task-5
If the marks of Robert in three subjects are 78,45 and 62 respectively (each
out of 100), write a program to calculate his total marks and percentage
marks.
#include <stdio.h>
int main() {
int marks1 = 78, marks2 = 45, marks3 = 62;
int total_marks;
float percentage;
return 0;
}
Task-6
Write a program to enter the values of two variables from the keyboard and
then interchange the values of the two variables. E.g
#include <stdio.h>
int main() {
int x, y, temp;
temp = x;
x = y;
y = temp;
printf("After interchange:\n");
printf("Value of x: %d\n", x);
printf("Value of y: %d\n", y);
return 0;
}
Task-7
The total number of students in a class are 45 out of which 25 are boys. If
80% of the total students secured grade ‘A’ out of which 17 are boys, then
write a program to calculate the total number of girls getting grade ‘A’.
#include <stdio.h>
int main() {
int total_students = 45;
int boys_total = 25;
int boys_grade_A = 17;
float grade_A_percentage = 80;
return 0;
}
Task-8
Write a program to calculate the sum of the first and the second last digit of
a 5 digits number.
Sample output:
NUMBER: 12345
OUTPUT: 1+4=5
#include <stdio.h>
int main() {
int number, first_digit, second_last_digit, sum;
return 0;
}
Task-9
Take a 4 digits number. Write a program to display a number whose digits
are 2 greater than the corresponding digits of the number TAKEN.
For example, if the number which was taken is 5696, then the displayed
number should be
7818.
#include <stdio.h>
int main() {
int number, displayed_number = 0;
int multiplier = 1;
multiplier *= 10;
number /= 10;
}
return 0;
}
Task-10
Write a program to calculate the sum of the digits of a 3-digit number.
Sample output:
Number: 132
Output: 6
#include <stdio.h>
int main() {
int number, sum = 0, digit;
return 0;
}
Task-11
Write a program to reverse a 3-digit number.
Sample output:
Number: 132
Output: 231
#include <stdio.h>
int main() {
int number, reverse = 0;
while (number != 0) {
int digit = number % 10;
reverse = reverse * 10 + digit;
number /= 10;
}