0% found this document useful (0 votes)
4 views5 pages

Programmig Code for SPL

The document contains multiple C programs: one to find the nth term of the Fibonacci series, another to find the largest element in an array of 10 integers, and a third to determine the middle number among three integers. Additionally, it includes a project on GPA grading using a structure to store student information and calculate GPA based on marks. Each program is well-structured with input prompts and output statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Programmig Code for SPL

The document contains multiple C programs: one to find the nth term of the Fibonacci series, another to find the largest element in an array of 10 integers, and a third to determine the middle number among three integers. Additionally, it includes a project on GPA grading using a structure to store student information and calculate GPA based on marks. Each program is well-structured with input prompts and output statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Q1. Write a C program to find nth term Fibonacci Series?

#include<stdio.h>
int fibonacciseries(int n)
{
int a=0,b=1,temp;
if(n==0) return a;
if(n==1) return b;
for(int i=2;i<=n;i++)
{
temp=a+b;
a=b;
b=temp;
}
return b;
}
int main (){
int n;
printf("Enter the position of fiboncchi term :");
scanf("%d",&n);
printf("The %d fibonacci term is %d\n",n,fibonacciseries(n));
return 0;
}

Q2. Write a C program to find the largest element in an array with 10


integers?
#include<stdio.h>
int main ()
{
int arr[10],i,max;
printf("Enter 10 integers: \n");
for(i=0;i<10;i++){
scanf("%d",&arr[i]);
}
max=arr[0];
for(i=1;i<10;i++)
{
if(arr[i]>max){
max=arr[i];
}
}
printf("The largest number of this arrey is: %d\n", max);
return 0;
}

Q3. Find the middle number of any three number?


#include<stdio.h>
int main ()
{
int num1,num2,num3,middlenum;
printf("Enter three integer number :\n");
scanf("%d%d%d",&num1,&num2,&num3);
if((num1>=num2&&num1<=num3)||(num1<=num2&&num1>=num3)){
middlenum=num1;}
else if ((num2>=num1&&num2<=num3)||(num2<=num1&&num2>=num3)){
middlenum=num2;}
else{
middlenum=num3;}
printf("The middle number is : %d\n",middlenum);
return 0;

Name: Sakibul Islam


Roll: B230305014
Sub: SPL

Project: Solving Structure Program using C


Title: GPA Grading

#include <stdio.h>
struct student {
char name[10];
int roll;
float marks[10];
};
int main() {
struct student s[10];
int n, k;
printf("\nEnter the students number: ");
scanf("%d", &n);
printf("\nEnter students subject number: ");
scanf("%d", &k);
for (int i = 0; i < n; i++) {
float sum = 0;
printf("\nEnter student name: ");
scanf("%s", s[i].name);
printf("\nEnter student roll: ");
scanf("%d", &s[i].roll);
int failed = 0;
for (int j = 0; j < k; j++) {
printf("\nEnter marks for subject %d: ", j + 1);
scanf("%f", &s[i].marks[j]);
int division = s[i].marks[j];
if (division < 40) {
failed = 1;
} else if (division < 45) { sum += 2; }
else if (division < 50) { sum += 2.25; }
else if (division < 55) { sum += 2.50; }
else if (division < 60) { sum += 2.75; }
else if (division < 65) { sum += 3.00; }
else if (division < 70) { sum += 3.25; }
else if (division < 75) { sum += 3.50; }
else if (division < 80) { sum += 3.75; }
else { sum += 4.00; }
}
if (failed) {
printf("Result: Fail\n");
} else {
printf("GPA: %.2f\n", sum / k);
}
}
return 0;
}

You might also like