Question: QN . 1 . Write a program in C to calculate the factorial of a given number using loops. QN . 2 . Write a

QN.1. Write a program in C to calculate the factorial of a given number using loops.
QN.2. Write a program in C to check whether a given number is prime or not.
QN.3. Modify the following code to use recursion instead of a loop:
#include
int main(){
int i;
for (i =1; i <=5; i++){
printf("%d
", i);
}
return 0;
}
QN.4.
What would be the output of:
#include
void display();
int main(){
printf("Welcome
");
display();
return 0;
}
void display(){
static int count =0;
printf("to C programming
");
count++;
if(count <3){
main();
}
}
QN.5. USING CONDITIONAL STATEMENTS, WRITE THE C PROGRAMMING CODE FOR THE FOLLOWING:
a. A parking lot charges $2 for the first hour or part thereof and $1.50 for each additional hour or part thereof. Ask the user for the number of hours parked and calculate the total charge.
b. A library charges a fine for books returned late. For the first 5 days, the fine is $0.50 per day, for 6 to 10 days the fine is $1 per day, and above 10 days the fine is $2 per day. Ask the user for the number of days the book is late and calculate the fine.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!