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 EMI(){
float princi, rate, time, EMI;
float r;
printf("Enter Principle Num: ");
scanf("%f", &princi);
printf("\nEnter Rate: ");
scanf("%f", &rate);
printf("\nEnter Time: ");
scanf("%f", &time);
r = rate/(12*100);
time = (time*12);
EMI = (princi * r * pow(1+r, time))/(pow(1+r, time)-1);
printf("Monthly EMI is= %.3f\n", EMI);
}
int main(){
EMI();
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 first = 0, second = 1, next, i;
printf("Fibonacci Series for %d terms:\n", n);
printf("%d %d ", first, second);
for (i = 3; i <= n; i++) {
next = first + second;
printf("%d ", next);
first = second;
second = next;
}
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, arr[100];
printf("Enter the 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 the 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 number of elements: ");
scanf("%d", &n);
printf("Enter %d elements:\n", n);
for(i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
printf("\nUpdated Array:\n");
for(i = 0; i < n; i++) {
if(arr[i] % 2 == 0)
printf("E ");
else
printf("%d ", arr[i]);
}
return 0;
}
Thus, the program to replace all even elements with 'E' in one dimensional array was verified successfully.




