1. Question:How to find a b and c in a quadratic equation in the format of ax^2+bx+c: 2x^2+4x+-1. 

    Answer
    #include<stdio.h>
    #include<math.h>
    
    int main(){
      float a,b,c;
      float d,root1,root2;  
    
      printf("Enter quadratic equation in the format ax^2+bx+c: ");
      scanf("%fx^2%fx%f",&a,&b,&c);
       
      d = b * b - 4 * a * c;
      
      if(d < 0){
        printf("Roots are complex number.\n");
       
        return 0;
      }
     
       root1 = ( -b + sqrt(d)) / (2* a);
       root2 = ( -b - sqrt(d)) / (2* a);
       printf("Roots of quadratic equation are: %.3f , %.3f",root1,root2);
    
      return 0;
    }
    Sample output: Enter quadratic equation in the format ax^2+bx+c: 2x^2+4x+-1 Roots of quadratic equation are: 0.000, -2.000






    1. Report
  2. Question:Write a c program to check given string is palindrome number or not 

    Answer
    #include<string.h>
    #include<stdio.h>
    int main(){
      char *str,*rev;
      int i,j;
      printf("\nEnter a string:");
      scanf("%s",str);
      for(i=strlen(str)-1,j=0;i>=0;i--,j++)
          rev[j]=str[i];
          rev[j]='\0';
      if(strcmp(rev,str))
          printf("\nThe string is not a palindrome");
      else
          printf("\nThe string is a palindrome");
      return 0;
    }






    1. Report
  3. Question:Write a program to generate the Fibonacci series in c 

    Answer
    #include<stdio.h>
    int main(){
        int k,r;
        long int i=0l,j=1,f;
    
        //Taking maximum numbers form user
        printf("Enter the number range:");
        scanf("%d",&r);
    
        printf("FIBONACCI SERIES: ");
        printf("%ld %ld",i,j); //printing firts two values.
    
        for(k=2;k<r;k++){
             f=i+j;
             i=j;
             j=f;
             printf(" %ld",j);
        }
      
        return 0;
    }
    Sample output: Enter the number range: 15 FIBONACCI SERIES: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377






    1. Report
  4. Question:Fibonacci series using array in c 

    Answer
    #include<stdio.h>
    int main(){
    
        int i,range;
        long int arr[40];
    
        printf("Enter the number range: ");
        scanf("%d",&range);
    
        arr[0]=0;
        arr[1]=1;
    
        for(i=2;i<range;i++){
             arr[i] = arr[i-1] + arr[i-2];
        }
    
        printf("Fibonacci series is: ");
        for(i=0;i<range;i++)
             printf("%ld ",arr[i]);
      
        return 0;
    }
    Sample output: Enter the number range: 20 Fibonacci series is: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181






    1. Report
  5. Question:Fibonacci series in c using while loop 

    Answer
    #include<stdio.h>
    int main(){
        int k=2,r;
        long int i=0l,j=1,f;
    
        printf("Enter the number range:");
        scanf("%d",&r);
    
        printf("Fibonacci series is: %ld %ld",i,j);
    
        while(k<r){
             f=i+j;
             i=j;
             j=f;
             printf(" %ld",j);
              k++;
        }
      
        return 0;
    }
    Sample output: Enter the number range: 10 Fibonacci series is: 0 1 1 2 3 5 8 13 21 34






    1. Report
Copyright © 2025. Powered by Intellect Software Ltd