To write a program to prepare EMI calculator using function without return type and with arguments.
- Start the program.
- Read principal amount, rate of interest and months.
- Pass these values as arguments to function.
- Calculate EMI using the formula, amt=(prpow(1+r,t))/(pow(1+r,t)-1)
- Display the result.
- Stop the program.
#include <stdio.h>
#include <math.h>
void calculateEMI(float principal, float rate, int months)
{
float r, emi;
r = rate / (12 * 100);
emi = (principal * r * pow(1 + r, months)) / (pow(1 + r, months) - 1);
printf("\nMonthly EMI = %.2f\n", emi);
}
int main()
{
float principal, rate;
int months;
printf("Enter principal amount: ");
scanf("%f", &principal);
printf("Enter annual interest rate (in %%): ");
scanf("%f", &rate);
printf("Enter loan period in months: ");
scanf("%d", &months);
calculateEMI(principal, rate, months);
return 0;
}
Thus the program to prepare EMI calculator using function without return type with arguments has been executed successfully
To write a C program to generate the Fibonacci series for the value 6.
- Start the program.
- Read number of terms to display.
- Add the previous two terms and store it in new term.
- Assign 2nd term to 1st term and 3rd term to 2nd term.
- Repeat steps 3 and 4 n number of times.
- Display the result.
- Stop the program.
#include <stdio.h>
int main()
{
int n = 6;
int a = 0, b = 1, c, i;
printf("Fibonacci series for %d terms:\n", n);
printf("%d %d ", a, b);
for(i = 3; i <= n; i++)
{
c = a + b;
printf("%d ", c);
a = b;
b = c;
}
printf("\n");
return 0;
}
Thus the program to generate the Fibonacci series for the value 6 has been executed successfully.
To write a C program to read n elements as input and print the last element of the array.
- Start the program.
- Read a variable.
- Read the array values n number of times.
- Print the last element.
- Stop the program.
#include <stdio.h>
int main()
{
int n, i;
int arr[100];
printf("Enter number of elements: ");
scanf("%d", &n);
printf("Enter %d elements:\n", n);
for(i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
}
printf("The last element is: %d\n", arr[n - 1]);
return 0;
}
Thus the program to read n elements as input and print the last element of the array has been executed successfully.
To write a C Program to count total number of positive elements in an array.
- Start the program.
- Read a variable.
- Read the array values n number of times.
- If the array value can be divided by 2 then increment count by 1.
- Display result.
- Stop the program.
#include <stdio.h>
int main()
{
int n, i, count = 0;
int arr[100];
printf("Enter number of elements: ");
scanf("%d", &n);
printf("Enter %d elements:\n", n);
for(i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
}
for(i = 0; i < n; i++)
{
if(arr[i] > 0)
{
count++;
}
}
printf("Total number of positive elements = %d\n", count);
return 0;
}
Thus the program to count total number of positive elements in an array has been executed successfully.
To write a C program to replace all even elements with 'E' in one dimensional array
- Input the array: Read the size of the array. Input the elements of the array.
- Iterate through the array: For each element of the array, check if the element is even (i.e., if the element modulo 2 equals 0).
- Replace even elements with 'E': If an element is even, replace that element with the character 'E'.
- Output the updated array: Print the updated array after replacements.
#include <stdio.h>
int main()
{
int n, i;
int arr[100];
printf("Enter the size of the array: ");
scanf("%d", &n);
printf("Enter %d elements:\n", n);
for(i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
}
printf("\nNew array:\n");
for(i = 0; i < n; i++)
{
if(arr[i] % 2 == 0)
printf("E ");
else
printf("%d ", arr[i]);
}
printf("\n");
return 0;
}
Thus, the program to replace all even elements with 'E' in one dimensional array was verified successfully.




