C programming Midterm Exam SPRING 2024 Model Answer
C programming Midterm Exam SPRING 2024 Model Answer
Explanation:
We cannot modify a constant integer value.
Explanation:
F(0) means false so the output will be the else probability “bye”.
#include <stdio.h>
const float PI = 3.14159;
int main()
{
float radius, area;
printf("Enter the radius of the circle: ");
scanf("%f", &radius);
return 0;
}
Solution:
#include <stdio.h>
int main() {
double num;
printf("Enter a number: ");
scanf("%lf", &num);
if (num <= 0.0) {
if (num == 0.0)
printf("You entered 0.");
else
printf("You entered a negative number.");
}
else
printf("You entered a positive number.");
return 0;
}
Page 2 of 3
Question IV: Looping: (10 Marks)
Write a C++ program to input a Positive Integer Number and calculate the Factorial of the Number.
Solution:
#include <stdio.h>
int main() {
int n, i;
unsigned long long fact = 1;
printf("Enter an integer: ");
scanf("%d", &n);
return 0;
}
Page 3 of 3