Tuesday, November 11, 2025

Input Fahrenheit Temperatures. Conversion into Celsius. C=(f-32)*5/9

 #include<stdio.h>
main()
{
    float f,c=0.0;
    printf("\nEnter Fahrenheit Temperatures : ");
    scanf("%f",&f);
    c=(f-32)*5.0/9.0;
    printf("\nCelsius = %f",c);
}



Result




Input Item No, Item Name, Quantity & Rate, Calculate Bill

 

#include<stdio.h>
main()
{
    int itno,qty;
    float rate,bill=0.0;
    char itname[10];
    printf("\nEnter Item No, Item Name, Qty. & Rate  : ");
    scanf("%d%s%d%f",&itno,itname,&qty,&rate);
    bill=qty*rate;
    printf("\nItem No = %d\nItem Name = %s\nBill = %.2f",itno,itname,bill);
}



Result



Thursday, October 30, 2025

Enter Coefficient of Quadratic Equations. Find the Properties of Equation.

#include<stdio.h>
#include<math.h>
main()
{
   float a,b,c;
   float d,r1,r2;
   /* 1 3 8        0 5 8       2 4 2     3 8 2 */
   printf("\n Enter the Values of A B C: ") ;
   scanf("%f%f%f", &a,&b,&c) ;
   d = b * b - 4 * a * c;
   if(a != 0)
   {
      if(d < 0)
      {
         r1=-b/(2*a);
         r2= sqrt(-d)/(2*a);
    printf("\n Roots are Complex/Imaginary.\n");
         printf("\n Root1 = %.3f%+.3fi",r1,r2);
         printf("\n Root2 = %.3f%+.3fi",r1,-r2);
      }
      else
      if(d==0)
      {
    printf("\n Both Roots are Real and Equal.\n");
    r1 = -b /(2* a);
    printf("\n Root1 = %.3f ",r1);
         printf("\n Root2 = %.3f ",r1);
      }
      else
      if(d > 0)
      {
    printf("\n Roots are Real  and Unequal.\n");
    r1 = ( -b + sqrt(d)) / (2* a);
    r2 = ( -b - sqrt(d)) / (2* a);
    printf("\n Root1 = %.3f , Root2 = %.3f",r1,r2);
      }
    }
    else
       printf("\n Equation is linear.");
}





Input 3 values. To find Triangle is Possible or Not. If Triangle is Possible then Find Nature of Triangle.

 


#include<stdio.h>
main()
{
    int a,b,c;
    printf("\n\nEneter 3 Values : ");
    scanf("%d%d%d",&a,&b,&c);
    if((a+b>=c) && (b+c>=a) && (c+a>=b))
    {
       printf("\nTriangle is Possible");
       if(a==b && b==c && c==a)
   printf("\nEquilateral Triangle");
       else
       if(a==b || b==c || c==a)
           printf("\nIsosceles Triangle");
       else
           printf("\nScalene Triangle");
     }
     else
          printf("\nTriangle is Not Possible"); 
}




Input Roll No, Student Name & 3 Subject Marks. To calculate Total, Avg. & Find Result is 'Pass' or 'Fail'



#include<stdio.h>
main()
{
     int rno,m1,m2,m3,tot=0;
     float avg=0.0;
     char sn[20];
     printf("\nEnter RNo. SName & 3 Subject Marks. ");
     scanf("%d%s%d%d%d",&rno,sn,&m1,&m2,&m3);
     tot=m1+m2+m3;
     avg=tot/3.0;
     printf("\nRoll No. %d\nSt. Name  %s\nTotal %d\Average %.2f",rno,sn,tot,avg);
     if(m1>=35 && m2>=35 && m3>=35)
          printf("\nResult is Pass");
    else
          printf("\nResult is Fail");
}





Find Biggest of given Two Numbers and Find Biggest of given Three Numbers.

Find Biggest of given Two Numbers


#include<stdio.h>
main()
{
    int a,b;
    printf("\nEnter A and B values");
    scanf("%d%d",&a,&b);
    if(a>b)
       printf("\nA is Big");
    else
       printf("\nB is Big");
}

        




Find Biggest of given Three Numbers.

#include<stdio.h>
main()
{
    int a,b,c;
    printf("\nEnter A,B and C values");
    scanf("%d%d%d",&a,&b,&c);
    if(a>b && a>c)
       printf("\nA is Big");
    else
    if(b>c)
       printf("\nB is Big");
    else
       printf("\nC is Big");
}

         

    (or)


#include<stdio.h>
main()
{
     int a,b,c;
     printf("\nEnter A B &  C Values : ");
     scanf("%d%d%d",&a,&b,&c);
     if(a>b)
          if(a>c)
             printf("\nA is Big  %d",a);
          else
             printf("\nC is Big  %d",c);  
     else
     if(b>c)
        printf("\nB is Big  %d",b);   
     else
        printf("\nC is Big  %d",c);
}






Wednesday, October 29, 2025

Decision Making in C (if - else)

 

Decision Making in C (if - else)

 

 

The if statement is powerful decision making statement in C. It is used to control the flow of execution of execution.

Types of if Statements in C

  1.   Simple if Statement
  2.   if...else  Statement
  3.   Nested if...else  Statement
  4.   if-else-if Ladder

 

Simple if Statements

The syntax of a Simple if Statement is

       if(condition)

            statement1;

       statements; 

  if condition is true then executed statement1 and followed statements. if condition is false executed statements.

 

The statement-block.

       if(condition)

      {  

            statement1;

            statement2;

            ---------

            statement n;

      }

      statements;

 

if condition is true then executed Block statements and followed statements. if condition is false executed statements.

 

if...else  Statement

 

        if(condition)

       {

            statement 1;

            statement 2;

            ----------

            statement n;

       } 

       else

       {

            statement 1;

            statement 2;

            ----------

            statement n;

       } 

       statements;

 

if condition is true then executed true Block statements and followed statements. if condition is false then executed false block statements and followed statements.

 

Nested if...else  Statement

Nested Condition: Condition in Condition is called Nested Condition.

 

         if(condition)
            if(condition)
               statement 1;
            else
               statement 2;
          else

            statement 3;

 

if condition is true then executed next if condition and it is true then excited statement1. if second if false  and executed statmenet2.if condition is false executed statements3.

 

if-else-if Ladder

 

The if-else-if Ladder is multipath decision.

   if(condition1)

      statement 1;

  else if(condition2)

      statement 2;

  else if(condition3)

      statement 3;

  -------

  else if(condition n)

      statement n;