<file_sep>#include <stdio.h>
#include <math.h>
void input(int *num);
void reverse_num(int num,char *reverse[],char *actual[]);
void compare_strings(char *a[],char *b[],int *equal);
void check_palindrome(char *reverse[],char *actual[]);
void main(){
    int num;
    char *actual[100];
    char *reverse[100];
    input(&num);
    printf("%d",num);
    reverse_num(num,reverse,actual);
    check_palindrome(reverse,actual);

}
void input(int *num){
    printf("Enter the number");
    int n;
    scanf("%d",&n);
    *num = n;
}
void reverse_num(int num,char *reverse[],char *actual[]){
    int num_of_digits,i;
    num_of_digits = log10(num)+1;
    char act[100];
    char rev[100];
    for(i=0;i<num_of_digits;i++){
        act[i] =num%10;
        rev[(num_of_digits-1)-i] =num%10;
        num /= 10;

        

    }
    printf("%s",act);
    *actual = act;
    *reverse = rev;
}
void compare_strings(char *a[],char *b[],int *equal){
    int i=0;
    while(*a[i]==*b[i]){
        if(*a[i]=='\0'||*b[i]=='\0'){
            break;
        }
        i++;
    }
    if(*a[i]=='\0'&&*b[i]=='\0'){
        *equal=0;
    }else{
        *equal=-1;
    }

}
void check_palindrome(char *reverse[],char *actual[]){
    int equal;
    compare_strings(reverse,actual,&equal);
    if(equal==0){
        printf("Yes,The number is a palindrome. %s",*actual);
    }else{
        printf("No,The number is not a palindrome. %s",*reverse);
    }
}<file_sep>#include <stdio.h>
#include <stdlib.h>
void input_dim(int *m,int *n){
	printf("Enter the dimensions of matrix");
	scanf("%d %d",m,n);
	if(*m!=*n){
		printf("Required a square matrix");
		exit(0);
	}
}
void input_matrix(int m,int n,float matrix[m][n]){
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			printf("Enter the element matrix[%d][%d]",i,j);
			scanf("%f",&matrix[i][j]);
		}
	}
}
void print_diagonal(int m,int n,float matrix[m][n]){
	for(int i=0;i<m;i++){
                for(int j=0;j<n;j++){
			if(i==j){
                        printf("%f ",matrix[i][j]);
			}
                        
                }       
        }  
}
void main(){
	int m,n;
	input_dim(&m,&n);
	float matrix[m][n];
	input_matrix(m,n,matrix);
	print_diagonal(m,n,matrix);
}
<file_sep>#include <stdio.h>
void input(char *vehicle,int *time){
	printf("Enter the first character of vehicle type and parking time");
	scanf("%c %d",vehicle,time);
}
void fares(char vehicle,int time,int *fare){
	int i=0;
	if(vehicle=='c'){
		if(time>2){
			*fare=(20*2)+(30*(time-2));
		}
		else if(time==2){
			*fare=(20*2);
		}
		else{
			*fare=(20);
		}
	}
	else if(vehicle=='b'){
		if(time>4){
                        *fare=(40*4)+(50*(time-4));
                }
                else if(time==4){
                        *fare=(40*4);
                }
                else{
                        *fare=(40)*(time);
                }
	}
	else{
		if(time>3){
                        *fare=(30*3)+(40*(time-3));
                }
                else if(time==3){
                        *fare=(30*3);
                }
                else{
                        *fare=(30)*(time);
                }
	}
}
void main(){
	int time,fare;
	char vehicle;
	input(&vehicle,&time);
	fares(vehicle,time,&fare);
	printf("The total fare for %c vehicle parked for %d hours is %d",vehicle,time,fare);
}







	

<file_sep>#include <stdio.h>
#include <math.h>
struct root{
	float real;
	float imaginary;
};
struct qequation{
	float a;
	float b;
	float c;
};
void input(struct qequation *e);
void find_roots(struct root *r1,struct root *r2,struct qequation e,float *d);
void output(struct root r1,struct root r2,float d);
void main(){
	struct qequation e;
	struct root r1;
	struct root r2;
	float d;
	input(&e);
	find_roots(&r1,&r2,e,&d);
	output(r1,r2,d);
}
void input(struct qequation *e){
	printf("Type the values of a,b,c of quadratic equation.");
	scanf("%f %f %f",&e->a,&e->b,&e->c);
}
/*
 * compute function recieves three parameters:
 * input parameters i : coefficients a,b,c
 * Outut parameters r1,c2 : roots of the quadratic equation if the root
 * Return Parameter : Value of Discrminant
 * Note: ( return value >= 0)  If roots are not complex imaginary part of c is zero
 */
void find_roots(struct root *r1,struct root *r2,struct qequation e,float *d){
	
	*d=(e.b*e.b) -(4*e.a*e.c);
	if (*d<0){
		r1->real = -e.b/(2*e.a);
		r1->imaginary = sqrt(-*d)/(2*e.a);
	
	}
	else if (*d==0){
		r2->real = -e.b/(2*e.a);
		r2->imaginary = 0;
	
	}
	else{
		r2->real = -e.b/(2*e.a);
		r2->imaginary = sqrt(*d)/(2*e.a);
	}
}
void output(struct root r1,struct root r2,float d){
	if (d<0){
		printf("The roots are imaginary. %f + %fi and %f + %fi",r1.real,r1.imaginary,r1.real,r1.imaginary);
	}
	else if(d==0){
		printf("The roots are equal. %f and %f",r2.real,r2.real);
	}else{
		printf("The roots are distinct. %f and %f", r2.real+r2.imaginary,r2.real-r2.imaginary);
	}

}

<file_sep>#include <stdio.h>
#include <math.h>
void input(int *n){
	printf("Enter the positive integer.");
	scanf("%d",n);
}
void is_armstrong(int n){
        int n_sub = n;
        int num_digits=log10(n)+1;
        int digits[num_digits];
        for(int i=0;i<num_digits;i++){
                digits[i]=(n%10)*(n%10)*(n%10);
                n/=10;
        }
        int arm_digit = 0;
        for(int i=0;i<num_digits;i++){
                arm_digit = arm_digit+digits[i];
        }
	if(arm_digit==n_sub){
		printf("Yes, it is a arstrong number. %d %d",n_sub,arm_digit);
	}else{
		printf("NO, it is not a armstrong number. %d %d",n_sub,arm_digit);
	}

}
void main(){
        int n;
        input(&n);
        is_armstrong(n);
}
<file_sep>#include <stdio.h>
void input(float a[]){
    printf("Enter three numbers.");
    scanf("%f %f %f",&a[0],&a[1],&a[2]);

}
/*
greatest_integer receives 2 parameter:
INPUT PARAMETERS a[]: array which contains input. 
OUTPUT PARAMETERS great: greatest number
RETURN PARAMETERS : doesn't return anything. 
*/
void greatest_integer(float *great,float a[]){
    if(a[0]>a[1]&&a[1]>a[2]){
        *great= a[0];
    }
    else if (a[1]>a[0]&&a[0]>a[2]){
        *great = a[1];
    }
    else{
        *great = a[2];
    }
}
void output(float great){
    printf("The greatest integer is = %f",great);
}
void main(){
    float a[3],great;
    input(a);
    greatest_integer(&great,a);
    output(great);

}<file_sep>#include <stdio.h>
#include <string.h>
void input(int *num){
    int n;
    printf("Enter the number");
    scanf("%d",&n);
    *num=n;
}
void check_palindrome(int num,int rev){
   if (num==rev)
        printf("Yes, The number is a palindrome. %d\n",rev);
   else
        printf("No, The number is not a palindrome. %d\n",rev);
    

}
void reverse(int num,int *rev){
    int r=0;
    while(num!=0){
        r = r*10+num%10;
        num/=10;

    }
    *rev=r;
}
void main(){
    int num,rev;
    input(&num);
    reverse(num,&rev);
    check_palindrome(num,rev);

}
<file_sep>#include <stdio.h>
void input(float *marks);
void grades(float marks,char *grade[]);
void output(char *grade[]);
void main(){
    float marks;
    char *grade[3];
    input(&marks);
    grades(marks,grade);
    output(grade);
}
void input(float *marks){
    printf("Type the marks.");
    float mar;
    scanf("%f",&mar);
    *marks = mar;
}
void grades(float marks,char *grade[]){
    
    if (marks>95){
        *grade = "A1\0";
    }
    else if(marks>85){
        *grade = "A2\0";
    }
    else if(marks>75){
        *grade = "B1\0";
    }
    else if (marks>60){
        *grade = "B2\0";
    }
    else if(marks>45){
        *grade = "C1\0";
    }
    else if(marks>40){
        *grade = "C2\0";
    }
    else if(marks>35){
        *grade = "D1\0";
    }
    else if(marks>30){
        *grade = "D2\0";
    }
    else{
        *grade = "E1\0";
    }
}
void output(char *grade[]){
    printf("Your grade is %s",*grade);
}
<file_sep>#include <stdio.h>
#include <stdlib.h>
void input(int *num){
	printf("Enter a positive number N");
	scanf("%d",num);
}
void print_primes(int num,int primes[],int *prime_count){
	int count  =0;
	if(num<2){
		printf("There are no prime numbers.");
		exit(0);
	}
	primes[count] = 2;
	count++;
	int i,j,is_prime;
	for(i=3;i<num;i+=2){
		is_prime=1;
		for(j=2;j<=(i/2);j++){
			if((i%j)==0){
				is_prime=0;
				break;
			}
		}
		if(is_prime==1){
			primes[count] = i;
			count++;
		}
	}
	*prime_count = count;
}
void output(int primes[],int prime_count){
	int i;
	printf("[");
	for(i=0;i<prime_count;i++){
		printf("%d, ",primes[i]);
	}
	printf("]");
}
void main(){
	int num;
	input(&num);
	int primes[num];
	int prime_count;
	print_primes(num,primes,&prime_count);
	output(primes,prime_count);
}



<file_sep>#include <stdio.h>
void input(char str[]){
	printf("Enter the string");
	scanf("%s",str);
}
void copy_str(char str[],char new_str[]){
	for(int i=0;i<100;i++){
		if(str[i]!='\0'){
		 	new_str[i] = str[i];
		}
		else{
			break;
		}
	}
	printf("Copied the string int a new string array.");
}
void main(){
	char str[100];
	input(str);
	char new_str[100];
	copy_str(str,new_str);
	
}
<file_sep>#include <stdio.h>
void input_dims(int *m,int *n){
    printf("Enter the dimensions of matrix");
    scanf("%d %d",m,n);
}
void input(int m,int n,float matrix[m][n]){
    printf("Enter the values of the matrix");
    int i,j;
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            printf("Enter the values of matrix[%d][%d]",i,j);
            scanf("%f",&matrix[i][j]);
        }
    }
}
void is_symmetric(int m,int n,float matrix[m][n],float mat_trans[m][n],int *result){
    int i,j,k,l;
    float tmp[m],tmp1[m];
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            for(k=0;k<n;k++){
                mat_trans[k][i]=matrix[i][k];
            }
            
            
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            if(mat_trans[i][j]==matrix[i][j]){
               *result = 0; 
            }
            else{
                *result = -1;
                break;
            }
            if(result==-1){
                break;
            }
        }
    }
}
void main(){
    int m,n;
    input_dims(&m,&n);
    float matrix[m][n],mat_trans[m][n];
    input(m,n,matrix);
    int i,j;
    printf("Real matrix\n");
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            printf("%f ",matrix[i][j]);
        }
        printf("\n");
    }
    int result;
    is_symmetric(m,n,matrix,mat_trans,&result);
    
    printf("Transpose matrix\n");
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            printf("%f ",mat_trans[i][j]);
        }
        printf("\n");
    }
    if(result==0){
        printf("THe matrix is a symmetric matrix");
    }
    else{
        printf("The matrix is not a symmetric matrix");
    }
    
}


<file_sep>#include <stdio.h>
void input_param(int *l,float *search){
	printf("Enter the length of array and the element to be searched");
	scanf("%d %f",l,search);
}
void input(int l,float array[l]){
	int i;
	printf("Enter the array elements");
	for(i=0;i<l;i++){
		printf("Enter the array[%d] element",i);
		scanf("%f",&array[i]);
	}
}
void linear_search(int l,float array[l],float search){
	int i;
	for(i=0;i<l;i++){
		if(array[i]==search){
			printf("The element to be searched is the %dth element in the array",i+1);
			break;
		}
		if(i==l){
			printf("The element was not found in the array");
		}
	}
}
void main(){
	int l;
	float search;
	input_param(&l,&search);
	float array[l];
	input(l,array);
	linear_search(l,array,search);
}

<file_sep>#include <stdio.h>
#include <math.h>
#include <complex.h>
struct roots{
    float real1;
    float real2;
    float complex imaginary1;
    float complex imaginary2;
};
struct quadratic{
    float a;
    float b;
    float c;
};
void input(struct quadratic *q);
void compute(struct roots *r,struct quadratic q,float *d);
void output(struct roots r,float d);
void main(){
    struct roots r;
    struct quadratic q;
    float d;
    input(&q);
    compute(&r,q,&d);
    output(r,d);
}
void input(struct quadratic *q){
    printf("Type the three coefficients of quadratic equation.");
    scanf("%f %f %f",&q->a,&q->b,&q->c);
}
/*
 * compute function recieves three parameters:
 * input parameters q : coefficients a,b,c
 * Outut parameters r,d : roots of the quadratic equation and value of d
 * Return Parameter : Value of Discrminant
 * Note: ( return value >= 0)  If roots are not complex imaginary parts of r is zero
 */
void compute(struct roots *r,struct quadratic q,float *d){
    *d=(q.b*q.b)-(4*q.a*q.c);
    if (*d<0){
        r->real1=(-q.b)/(2*q.a);
        r->real2=r->real1;
        float complex c = ((*d)/(4*q.a*q.a));
        r->imaginary1=csqrt(c);
        r->imaginary2=r->imaginary1;
    }
    else if (*d==0){
        r->real1=(-q.b)/(2*q.a);
        r->real2=r->real1;
        r->imaginary1=0*I;
        r->imaginary2=r->imaginary1;
    }
    else{
        r->real1=(-q.b+sqrtf(*d))/(2*q.a);
        r->real2=(-q.b-sqrtf(*d))/(2*q.a);
        r->imaginary1=0*I;
        r->imaginary2=r->imaginary1;
    }
}
void output(struct roots r,float d){
    if (d<0){
        printf("The roots are complex %f + %fi and %f - %fi",r.real1,cimag(r.imaginary1),r.real2,cimag(r.imaginary2));
    }
    else if (d==0){
        printf("The roots are real and equal %f and %f",r.real1,r.real2);
    }
    else{
        printf("The roots are real and distinct %f and %f",r.real1,r.real2);
    }
}
<file_sep>#include <stdio.h>
void swap(int *a,int *b){
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}
	

void main(){
	int a=10,b=20;
	swap(&a,&b);
	printf("%d %d",a,b);
}
<file_sep>#include <stdio.h>
#include <stdlib.h>
struct matrix_dim{
	int rows;
	int col;
};
void input_dim(struct matrix_dim *mat1,struct matrix_dim *mat2){
	printf("Enter the values of matrix 1 rows,cols");
        scanf("%d %d",&mat1->rows,&mat1->col);
        printf("Enter the values of matrix 2 rows,cols");
        scanf("%d %d",&mat2->rows,&mat2->col);
        if(mat1->col!=mat2->rows){
                printf("Invalid matrix dimensions.");
                exit(0);
        }

}
void input(struct matrix_dim mat1,struct matrix_dim mat2,float matrix1[mat1.rows][mat1.col],float matrix2[mat2.rows][mat2.col]){
	int i,j;
	for(i=0;i<mat1.rows;i++){
		for(j=0;j<mat1.col;j++){
			printf("Enter the value of matrix1[%d][%d]",i,j);
			scanf("%f",&matrix1[i][j]);
		}
	}
	for(i=0;i<mat2.rows;i++){
                for(j=0;j<mat2.col;j++){
                        printf("Enter the value of matrix2[%d][%d]",i,j);
                        scanf("%f",&matrix2[i][j]);
                }       
        } 
}
void multiply(struct matrix_dim mat1,struct matrix_dim mat2,float matrix_final[mat1.rows][mat2.col],float matrix1[mat1.rows][mat1.col],float matrix2[mat2.rows][mat2.col]){
	int i,j,k;
	float sum=0;
	for(i=0;i<mat1.rows;i++){
		for(j=0;j<mat2.col;j++){
			for(k=0;k<mat1.col;k++){
				sum = sum+matrix1[i][k]*matrix2[k][j];
			}
			matrix_final[i][j]=sum;
			sum=0;

		}
	}
}
void print_matrix(struct matrix_dim mat1,struct matrix_dim mat2,float matrix_final[mat1.rows][mat2.col]){
	int i,j;
	printf("Matrix final is :\n");
        for(i=0;i<mat1.rows;i++){
                for(j=0;j<mat2.col;j++){
                        printf(" %f ",matrix_final[i][j]);
                }
                printf("\n");
        }
}


void main(){
	struct matrix_dim mat1;
	struct matrix_dim mat2;
	input_dim(&mat1,&mat2);
	float matrix1[mat1.rows][mat1.col],matrix2[mat2.rows][mat2.col],matrix_final[mat1.rows][mat2.col];

	input(mat1,mat2,matrix1,matrix2);
	multiply(mat1,mat2,matrix_final,matrix1,matrix2);
	int i,j;
	printf("Matrix 1 is :\n");
	for(i=0;i<mat1.rows;i++){
                for(j=0;j<mat1.col;j++){
                        printf(" %f ",matrix1[i][j]);
                }
		printf("\n");
        }
	printf("Matrix 2 is :\n");
        for(i=0;i<mat2.rows;i++){
                for(j=0;j<mat2.col;j++){
                        printf(" %f ",matrix2[i][j]);
                }
                printf("\n");
        }
	print_matrix(mat1,mat2,matrix_final);


}

<file_sep>#include <stdio.h>
void input(int *m,int *n){
	printf("Enter two numbers");
	scanf("%d %d",m,n);
}
void swap(int *m,int *n){
	int tmp;
	tmp = *m;
	*m = *n;
	*n = tmp;
}
void main(){
	int m,n;
	input(&m,&n);
	swap(&m,&n);
	printf("The swapped numbers m = %d and n = %d",m,n);
}
<file_sep>#include <stdio.h>
void bubble_sort(float a[],float length);
void input_length(int *length);
void input_array(float a[],float length);
void output(float a[],float length);
void main(){
    int length;
    input_length(&length);
    float a[length];
    input_array(a,length);
    bubble_sort(a,length);
    output(a,length);

}
void input_length(int *length){
    printf("Enter length of array");
    int len;
    scanf("%d",&len);
    *length = len;
}
void input_array(float a[],float length){
    printf("Enter the elements");
    int i;
    for(i=0;i<length;i++){
        printf("Enter the value for a[%d]",i);
        scanf("%f",&a[i]);
    }
}
/*
bubble_sort receives 2 parameter:
INPUT PARAMETERS a[],length: array and length of array.
OUTPUT PARAMETERS sorted array a[]: sorted array
RETURN PARAMETERS : doesn't return anything. 
*/
void bubble_sort(float a[],float length){
    int i,j,swap_count;
    float tmp;
    for(i=0;i<length-1;i++){
        swap_count=0;
        for(j=0;j<length-i-1;j++){
            if (a[j]>a[j+1]){
                tmp=a[j];
                a[j]=a[j+1];
                a[j+1]=tmp;
                swap_count++;

            }
        }
        if(swap_count==0){
            break;
        }
    }
}
void output(float a[],float length){
    int i;
    for(i=0;i<length;i++){
        printf("%f \n",a[i]);
    }
}<file_sep>#include <stdio.h>
void input(int *n){
	printf("ENter the total number of fibonacci numbers.");
	scanf("%d",n);
}
void fib(int n){
	int count =0;
	int i,fib;
	int f1 =0;
	int f2 = 1;
	printf("%d ",f1);
	printf("%d ",f2);
	while(count<(n-2)){
		fib = f1+f2;
		f1 = f2;
		f2 = fib;
		printf("%d ",fib);
		count++;
	}
}
void main(){
	int n;
	input(&n);
	fib(n);
}
		

<file_sep>#include <stdio.h>
#include <math.h>
struct complex{
	float real;
	float imaginary;
};
struct inputs{
	float a;
	float b;
	float c;
};
struct real{
	float root1;
	float root2;
};
void input(struct inputs *i);
float compute(struct complex *c,struct real *r,struct inputs i);
void output(struct complex c,struct real r,float d);
void main(){
	struct inputs i;
	struct complex c;
	struct real r;
	float d;
	input(&i);
	d = compute(&c,&r,i);
	output(c,r,d);
}
void input(struct inputs *i){
	printf("Type the values of a,b,c");
	scanf("%f %f %f",&i->a,&i->b,&i->c);
}
float compute(struct complex *c,struct real *r,struct inputs i){
	float d;
	d = (i.b*i.b) -(4*i.a*i.c);
	if (d<0){
		c->real = -i.b/(2*i.a);
		c->imaginary = sqrt(-d)/(2*i.a);
	
	}
	else if (d==0){
		r->root1 = -i.b/(2*i.a);
		r->root2 = -i.b/(2*i.a);
	
	}
	else{
		r->root1 = -i.b+sqrt(d);
		r->root2 = -i.b-sqrt(d);
	}
	return d;
}
void output(struct complex c,struct real r,float d){
	if (d<0){
		printf("The roots are imaginary. %f + %fi and %f + %fi",c.real,c.imaginary,c.real,c.imaginary);
	}
	else if(d==0){
		printf("The roots are equal. %f and %f",r.root1,r.root2);
	}else{
		printf("The roots are distinct. %f and %f",r.root1,r.root2);
	}

}

		

<file_sep>#include <stdio.h>
void input(int *n,int *r){
	printf("Enter the values of n and r");
	scanf("%d %d",n,r);
}
void factorial(int num,int *fact){
	int i;
	*fact = 1;
	for(i=1;i<=num;i++){
		*fact =  *fact*i;
	}
		
	
}
void npr(int n,int r){
	int n_fact;
	factorial(n,&n_fact);
	int n_r_fact;
	factorial((n-r),&n_r_fact);
	printf("npr value for n = %d and r = %d is =  %d",n,r,(n_fact/n_r_fact));
}
void ncr(int n,int r){
	int n_fact;
	factorial(n,&n_fact);
	int r_fact;
	factorial(r,&r_fact);
	int n_r_fact;
	factorial((n-r),&n_r_fact);
	printf("\nncr value for n = %d and r = %d is = %d ",n,r,(n_fact/(n_r_fact*r_fact)));
}
void main(){
	int n,r;
	input(&n,&r);
	npr(n,r);
	ncr(n,r);
}
<file_sep>#include <stdio.h>
void main(){
    printf("Commiting C program on github.");
}<file_sep>#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float * input();
float * compute();
void output();
void main(){
    float *p;
    p = input();
    /*int loop;
    for(loop=0;loop<3;loop++)
        printf("%f ",p[loop]);*/
    float *c;
    c = compute(p);
    free(p);
    /*if (c==NULL){
        printf("The function doesn't have root.");
    }else{
        int loop1;
        for(loop1=0;loop1<2;loop1++)
            printf("%f ",c[loop1]);

    }*/
    output(c);
    free(c);



}
/*1)To return a array we use asterisk 
  2)Since it is not possible to return local address because once 
    we come out of the function the local address is not used anymore 
    therefore it is important to import stdlib and call malloc to create space 
    so that , that particular memory address is returned.
  */
float * input(){
    float *nums = malloc(sizeof(float)*3);
    printf("Type the values for a,b,c and press enter after each number.");
    scanf("%f %f %f",&nums[0],&nums[1],&nums[2]);
    return nums;
}
/*1)To return an array we use asterisk 
  2)Since it is not possible to return local address because once 
    we come out of the function the local address is not used anymore 
    therefore it is important to import stdlib and call malloc to create space 
    so that , that particular memory address is returned.
  3)I will first check if the function has roots and then return root if it has or else return NULL
  4)For square root (sqrt) function I have used math.h header file.
  */
float * compute(float *arr){
    float a,b,c;
    a=arr[0];
    b = arr[1];
    c = arr[2];
    float x_plus;
    float x_minus;
    float *results = malloc(sizeof(float)*3);
    float d = (b*b)-4*a*c;
    if (d<0){
        float real,imaginary;
        real = (-b)/(2*a);
        imaginary = (sqrtf(-d))/(2*a);
        results[0]=real;
        results[1]=imaginary;
        results[2]=d;
        return results;

    }
    else{
        x_plus = (-b + sqrtf(d))/(2*a);
        x_minus = (-b - sqrtf(d))/(2*a);
        results[0]=x_plus;
        results[1]=x_minus;
        results[2]=d;

    }
    return results;
    

}
/*1)To return a array we use asterisk 
  2)Printf is used fromm stdio.h header file to print on the terminal.
  */
void output(float *a){
    if (a[2]<0){
        printf("The given quadratic equation has imaginary roots. %f+i(%f) and %f-i(%f)",a[0],a[1],a[0],a[1]);
    }
    else{
        printf("The two roots are %f %f",a[0],a[1]);
    }
}<file_sep>#include <stdio.h>
void input_dim(int *l){
	printf("Enter the length of the array");
	scanf("%d",l);
}
void input(int l,float array[l]){
	for(int i=0;i<l;i++){
		printf("Enter the element array[%d]",i);
		scanf("%f",&array[i]);
	}
}
void selection_sort(int l,float array[l]){
	int pos,tmp,pos_ele;
	for(int i=0;i<(l-1);i++){
		pos = i;
		pos_ele = array[i];
		for(int j=i+1;j<(l);j++){
			if(pos_ele>array[j]){
				pos = j;
			}
		}
		if(pos!=i){
			tmp = array[i];
			array[i] = array[pos];
		        array[pos]=tmp;
		}
	}
}
void main(){
	int l;
	input_dim(&l);
	float array[l];
	input(l,array);
	selection_sort(l,array);
	printf("The sorted array is [");
	for(int i=0;i<l;i++){
		printf("%f, ",array[i]);
	}
	printf("]");
	printf("The maximum element is %f and minimum element is %f",array[l-1],array[0]);

}


<file_sep>#include <stdio.h>
void input(int *rows){
	printf("enter number of rows.");
	scanf("%d",rows);
}
/*
print_triangle receives 1 parameter:
INPUT PARAMETERS rows: no. of rows of triangle
OUTPUT PARAMETERS printf: prints the triangle
RETURN PARAMETERS : doesn't return anything.
Note: It will print a triangle with equal sides of n number of rows. 
*/
void print_triangle(int rows){
	int i,white_space,j;
	for(i=0;i<rows;i++){
		white_space=(rows)-(i+1);
		printf("%*s",white_space,"");
		for(j=0;j<(2*(i+1)-1);j++){
			printf("*");
		}
		printf("\n");
	}
}
void main(){
	int rows;
	input(&rows);
	print_triangle(rows);

}


<file_sep>#include <stdio.h>
struct student{
	int roll;
	char name[100];
	char dept[100];
	int marks;
	char grade[10];
};
void input_data(int index,struct student *studs){
	printf("Enter the student roll.");
	scanf("%d",&studs->roll);
	printf("Enter the student name.");
        scanf("%s",studs->name);
	printf("Enter the student dept.");
        scanf("%s",studs->dept);
	printf("Enter the student marks.");
        scanf("%d",&studs->marks);
	printf("Enter the student grade.");
        scanf("%s",studs->grade);
}

void print_data(int length,struct student studs[],int roll){
	int done = 0;
	for(int i=0;i<length;i++){
		if(studs[i].roll==roll){
			printf("The student data is : %d %s %s %d %s",studs[i].roll,studs[i].name,studs[i].dept,studs[i].marks,studs[i].grade);
			done = 1;
			break;
		}

	}
	if(done==0){
		printf("THere is no such student.");
	}
}

void get_roll(int *roll){
	printf("Enter the roll number");
	scanf("%d",roll);
}
void main(){
	int roll,index=0;
	struct student studs[100];
	input_data(index,&studs[index]);
	index++;
	get_roll(&roll);
	print_data(index,studs,roll);
}









<file_sep>#include <stdio.h>
void input_length(int *length);
void input_array(float a[],int length);
void input_search_ele(float *search);
void binary_search(float a[],float length,int *index,float search);
void output(int index);

void main(){
    int length,index;
    input_length(&length);
    float a[length],search;
    input_array(a,length);
    input_search_ele(&search);
    binary_search(a,length,&index,search);
    output(index);
}

void input_length(int *length){
    int len;
    printf("Enter the length of array");
    scanf("%d",&len);
    *length = len;
}
void input_array(float a[],int length){
    int i;
    for(i=0;i<length;i++){
        printf("Enter the value of a[%d]",i);
        scanf("%f",&a[i]);
    }

}
void input_search_ele(float *search){
    float s;
    printf("Enter the value to search");
    scanf("%f",&s);
    *search = s;
}
/*
binary_search receives 4 parameter:
INPUT PARAMETERS a[],length,search: array,it's length and element to be searched respc.
OUTPUT PARAMETERS index: Index of the element.
RETURN PARAMETERS : doesn't return anything.
*/
void binary_search(float a[],float length,int *index,float search){
    int first_index,last_index,mid_index;
    first_index=0;
    last_index=length-1;
    mid_index = (first_index+last_index)/2;
    while(first_index<=last_index){
        if(a[mid_index]==search){
            *index = mid_index+1;
            break;
        }
        else if(a[mid_index]<search){
            first_index = mid_index+1;
        }
        else{
            last_index = mid_index-1;
        }
        mid_index = (first_index+last_index)/2;
    }
    if(first_index>last_index){
        *index = -1;
    }
}
void output(int index){
    if(index==-1){
        printf("Your key element was not found in the given array");
    }
    else{
        printf("The given element is located at %dth position.",index);
    }
}