Coding Questions
Coding Questions
Coding Questions
function.
#include <stdio.h>
void Area_Perimeter();
int main() {
Area_Perimeter();
void Area_Perimeter() {
/* Variable Declaration. */
float PI=3.14;
scanf("%f", &radius);
perimeter = 2 * PI * radius;
}
Write a C program to make a simple calculator that performs arithmetic operations using
functions.
#include <stdio.h>
return a + b;
return a - b;
return a * b;
if (b != 0) {
return a / b;
} else {
}
int main() {
char operator;
scanf("%f", &num1);
scanf("%f", &num2);
switch (operator) {
case '+':
break;
case '-':
break;
case '*':
break;
case '/':
default:
return 0;
}
Write a program in c to swap the values of two variables using call by value.
#include<stdio.h>
int temp;
temp = a;
a = b;
b = temp;
int main(void) {
scanf("%d,%d",&first,&second);
swap(first,second);
//printf("\n After swap function called 1st number is %d and 2nd number is %d", first ,second);
return 0;
}
Write a program in c to calculate factorial of a number using recursion.
#include<stdio.h>
long factorial(int n)
if (n == 0)
return 1;
else
return(n * factorial(n-1));
void main()
int number;
long fact;
scanf("%d", &number);
fact = factorial(number);
return 0;
}
Write a program in c to print Fibonacci series using recursion.
#include <stdio.h>
int fibonacci(int i) {
if(i == 0) {
return 0;
if(i == 1) {
return 1;
int main() {
int i;
printf("%d\t\n", fibonacci(i));
return 0;