Showing posts with label Nested if. Show all posts
Showing posts with label Nested if. Show all posts

write a program to accept two number and find out the largest among them

two number largest,

 /*write a program to accept two number and find out the largest among them*/

#include<stdio.h>

#include<conio.h>

void main()

{                int a,b;

                 clrscr();

                 printf(" \n Enter two number =");

                 scanf("%d%d",&a,&b);

                if(a==b)

                      printf("\n Both are equal ");

                elseif(a>b)

                       printf("\n %dis largest ",a);

                else

                       printf("\n %dis largest ",b);

                getch();

}


/* Output :---

                   Enter two number =  20

                                                     30

                    20 is largest.

                    OR

                   Enter two number =  20

                                                     20

                   Both are equal

*/                                                                      👇😊💬💭👌

write a program to find out the largest among three number

 /* write a program to find out the largest among three number by use Nested if*/

#include<stdio.h>

#include<conio.h>

void main()

{                int a,b,c;

                  clrscr();

                  printf("\n Enter three number = ");

                  scanf("%d%d%d",&a,&b,&c);

                  if(a>b)

                   {     if(a>c)

                                          printf("%d is largest" ,a);

                          else

                                          printf("%d is largest" ,c);

                    }

                    else

                    {      if(b>c)

                                         printf("%d is largest" ,b);

                           else

                                         printf("%d is largest" ,c);   

                     }

                     getch();

}

/* Output :---

                 Enter three number = 56 

                                                    20

                                                      7

                   56 is largest .

*/




                                                                    👇💬💭😊👌

write a program to find the roots of the quadratic equation where the value of a, b, and c are entered by user

/* write a program to find the roots of the quadratic equation where the value of a, b, and c are entered by user*/

# include<stdio.h>

#include<conio.h>

void main()

{                float a,b,c,term,r1,r2;

                 printf("\n Enter the value for a,b and c =\n");

                 scanf("%f%f%f ",&a,&b,&c);

                 term= b*b-4*a*c;

                if(term<0)

                                printf( "\n Imaginary Roots ");

                elseif(term==0)

          {    printf("\n Roots are real and equal");

                r1= -b/(2*a);

                r2=r1;

                printf("\n r1=%f",r1);

                printf("\n r2=%f",r2);

          }

             elseif(term>0)

         {  printf("\n Roots are real and  and distinct")

             r1=(-b+sqrt(term))/(2*a);

             r2=(-b-sqrt(term))/(2*a)

            printf("\n r1=%f",r1);

            printf("\n r2=%f",r2);

         }

           getch();

}        

/*- output :--

                    Enter the value for a,b and c =1

                                                                     2

                                                                     3

                     Imaginary Roots

*/



                                   
                                                        👆😊💬💭

write a program to accept a number and check if it is odd or even


 /* write a program to accept a number and check if it is odd or even */

#include<stdio.h>

#include<conio.h>

void main()

{                int n;

                  clrscr();

                  printf("\n Enter a number = ");

                  scanf("%d%d",&n);

                  if(n/2==0)

                                printf("\n%d is Even",n);

                  eles

                                printf("\n %d is Odd",n)

                  getch();

}

/*Output :---

Enter a number = 4    Or    Enter a number = 5

Even                                   Odd

*/                                                                 

                                                                  👇💬😊💭              

find out the largest between 2 number


/* write a program to find out the largest between 2 number */

#include<stdio.h>

#include<conio.h>

void main()

{                  int a,b;

                    clrscr();

                    printf(" \n Enter two number = ");

                    scanf("%d%d",&a,&b);

                    if(a>b)

                                  printf("%d is largest ",a);

                   else

                                 printf("%d is largest ",b);

                   getch();

}

/*output:---

             Enter two number =10

                                             20

            20 is largest

*/


                                                                 ðŸ‘†ðŸ‘ŒðŸ˜ŠðŸ˜‰

Decision Making (Using if )theory

 Decision Making Using if

1) keyword is a reserved word i.e a word which is already available in c language .there are 32 keywords available in c language.

2) if is a keyword is used to check condition and that basis we can take some decision , decision is based on whether the condition is true or false

syntax :

1) if  (condition)

                        true part;( i.e statement1)

2) if  (condition)

                        true part;( i.e statement1)

    else
                       false part; (i.e statement1)


3) if  (condition)
{                       statement 1;

                         statement 2;

                         statement 3;

}

    else

                         statement ;

4)  if  (condition)

{                       statement 1;

                         statement 2;

                                |

                                |

                         statement n;

}

    else

{                       statement 1;

                         statement 2;

                                |

                                |

                         statement n;

}

Example :--

/* program to find out the result pass or fail on the basis of marks of student where 35 and 35 above is pass*/

#include<stdio.h>

#include<conio.>

void main()

{                int marks;

                  clrscr();

                  printf(" \n Enter the your marks =" );

                  scanf("%d",&marks);

                  if(marks>=35)

                                        printf(" pass");

                  else

                                        printf(" fail ");

                  getch();

}


/* output :---

 Enter the your marks = 45

  pass

*/


                                                                 ðŸ’¬ðŸ˜ŠðŸ˜‰ðŸ‘Œ

write a program to find out the number check +ve,-ve,or zero



 /* write a program to find out the number  check +ve , -ve, or zero */


#include<stdio.h>

#include<conio.h>

main()

{    int a ;

     printf("\n enter a number =");

     scanf("%d ",a);

     if(a==0)

        printf(" is zero");

     else if(a>0)

        printf("%d  number is +ve",a);

     else

        printf("%d  number is   -ve",a);

     getch();


}

/*

Out put 

enter a number = 5

number is +ve

*/


Flowchart of program


                                                            ðŸ‘ŒðŸ˜ŠðŸ˜€







c program, Advance coding, c++ program, simple program, Advance language

online quiz Application project page MCA final year project

  Here we making a quiz application ppt presentation for college project so that our project idea will like to our professor and teacher  fi...