Posts

Showing posts from January, 2022

Eligible for vote or not in C programming

Image
 QUESTION :                    Eligible for vote or not  :-(using If-Else ladder )   SOURCE CODE :   int main () { int age ; printf ("Enter your own age "); scanf (" %d",&age); if (age>=18) { printf (" Yes, you are eligible for vote  "); } else  { printf (" Sorry ,now you are not eligible for vote  "); } return 0; } INPUT : OUTPUT :                                                                                                       ------ THANK YOU FOR VISITING THIS PAGE 

Find The Largest Number Among Three Numbers

Image
                       QUESTION :          Find the Largest Number Among Three Numbers SOURCE CODE :- #include <stdio.h> int main () { int num1,num2,num3; printf (" enter three number "); scanf (" %d%d%d",&num1,&num2,&num3); if (num1>=num2&&num1>=num3) { printf("num 1 is bigger=%d ",num1); } else if (num2>=num1&&num2>=num3) { printf ("num 2 is bigger=%d ",num2); } else  printf (" num 3 is bigger=%d ",num3); return 0 ; } INPUT :- OUTPUT :-                                                                      ------ THANK YOU FOR VISITING THIS PAGE

HOW TO FIND THE SIZE OF VARIOUS DATATYPE :-

Image
 QUESTION :                    HOW TO FIND THE SIZE OF VARIOUS DATATYPE   SOURCE CODE : #include <stdio.h> int main () {   int intType ;   float floatType;   char  charType;   printf ("%zu\n",sizeof (intType));   printf ("%zu\n",sizeof (floatType ));   printf ("%zu\n",sizeof(charType));   return 0;   } INPUT: OUTPUT :  We can see  in output box that our compiler print the size of int, float, character datatype easily . N.B-    sizeof (intType) is an  build in operator.                                                                                ------- Thank u for visiting this page 

COMPUTE THE QUOTIENT & REMAINDER OF TWO NUMBER ENTERED BY USER :-

Image
 QUESTION :-                  COMPUTE QUOTRIENT & REMAINDER   SOURCE CODE:- #include <stdio.h> int main () { int a,b,rem,quot;      //declaration part printf ("enter the value of a &b \n");        //to print the output  scanf (" %d%d",&a,&b);            //to take the input from the user rem=a%b; quot=a/b; printf ("rem=%d and quot=%d ",rem,quot); return 0 ;              //it will not return any exit value  } INPUT: OUTPUT:-                                                                                                                                        ------THANK YOU FOR VISITING THIS PAGE    

Swapping Operation using third variable :-

Image
QUESTION: Swapping operation using third variable (temp)  #include < stdio.h > int main () { int a, b, temp; //a=10,b=20 printf ( "enter the value of a &b " ); // to print the output scanf ( "%d%d" ,&a,&b); // to take the input from the user temp=a; //temp=10 a=b; //10=20 b=temp; //b=10, now a=30-b=30-10=20 printf ( "after swapping a =%d and after swapping b=%d \n " ,a,b); return 0 ; } INPUT : OUTPUT:                                                                                --- THANK YOU FOR VISITING THIS PAGE 

The year entered by the user is a leap year or not.

Image
Main program:-  //leap year or not #include <stdio.h> int main()  {    int year;    printf("Enter a year: ");    scanf("%d", &year);    // leap year if perfectly divisible by 400    if (year % 400 == 0)     {       printf("%d is a leap year.", year);    }    // not a leap year if divisible by 100    // but not divisible by 400    else if (year % 100 == 0)     {       printf("%d is not a leap year.", year);    }    // leap year if not divisible by 100    // but divisible by 4    else if (year % 4 == 0)     {       printf ("%d is a leap year.", year);    }    // all other years are not leap years    else {       printf("%d is not a leap year.", year);    }    return 0; } CODE: OUTPUT: //In the case of Non-leap year- //In the case of leap-year-                                                                                             - Thank you for visiting this page