Embedded C Class Assignment 1 - 22BLC1339
Embedded C Class Assignment 1 - 22BLC1339
Submitted By
22BLC1339 - Shweta S
Submitted To
Dr. Balakrishnan R
DATE: 23/01/2024
Code 1:
Answer: z = 6
Answer:
The letter "C" is printed once for each of the four iterations where the condition is true.
∴ C is printed 4 times
Answer:
Code:
C/C++
#include <stdio.h>
int main() {
printf("22BLC1339\n");
int number = 5;
while (number <= 20) {
printf("%d\n", number);
number++;
}
return 0;
}
(b)
● For (a): The printf function will print the result of the comparison, 8< 10, which is
1(True).
● For (b): Undefined Error: Floating point exception. Error is due to the division by zero.
Error messages vary for compiler.
5.
Answer:
Answer:
Final Output:
22BLC1339
Step 1: c = 1
Step 2: c = 0
Final c = 0
8. Debug the below code.
Code:
C/C++
#include <stdio.h> int main() {
int x = 5;
while (x = 5)
printf("In the loop\n");
x--;
}
return 0;
}
Answer:
In the original code, the code will lead to an infinite loop, causing a run-time error. That’s why, I
changed it to x>0, causing getting an output for 5 times.
9.
Answer: No this will not compile due to a few errors.(Image 1),The corrected code is in Image 2.
11.
22BLC1339 10
Programming BECE320E – Embedded C
Answer:
The error message: Incrementing a Macro: You cannot increment a macro as if it were a variable.
Answer: Corrected
12.
Answer:
22BLC1339 11
Programming BECE320E – Embedded C
22BLC1339 12
Programming BECE320E – Embedded C