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 cemi(float p, float r, float n) { float emi; r = r / (12 * 100); /* one month interest / n = n * 12; / total months */ emi = (p * r * pow(1 + r, n)) / (pow(1 + r, n) - 1); printf("Monthly EMI is= %.3f\n", emi); }
int main() { float principal, rate, time; printf("Enter principal, rate, and time: "); scanf("%f %f %f", &principal, &rate, &time); cemi(principal, rate, time); 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, next;
printf("Fibonacci Series for %d terms:\n", n);
printf("%d, %d", a, b);
for (int i = 3; i <= n; i++) {
next = a + b;
printf(", %d", next);
a = b;
b = next;
}
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; printf("Enter the number of elements: "); scanf("%d", &n); int arr[n]; printf("Enter %d elements:\n", n); for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } printf("The last element of the array 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, c = 0; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); if (a[i] > 0) { c++; } } printf("count of positive numbers in array: %d\n", c); 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; printf("Enter Number of elements: "); scanf("%d", &n); char arr[n]; printf("Enter elements: "); for (int i = 0; i < n; i++) { scanf(" %c", &arr[i]); if ((int)arr[i] % 2 == 0) arr[i] = 'E'; } for (int i = 0; i < n; i++) { if (arr[i] == 'E') { printf("E "); } else { printf("%c ", arr[i]); } } printf("\n"); return 0; }
Thus, the program to replace all even elements with 'E' in one dimensional array was verified successfully.




