Thursday, 27 May 2021

C problems

 

//write a program to find largest number btw thw num
//author:upendra yadav date:10/29/2020
#include<stdio.h>
void main()
{
int num1,num2;
printf("Enter the two numbers to compare :\n");
scanf("%d%d",&num1,&num2);
if(num1>num2?num1:num2)
printf("greater number is %d",num2);
else
{

printf("greater number is %d",num1);


}



}

2.)

 #include <stdio.h>
#include <conio.h>

int main()
{
    /*
      Declaration of variables used
    */

    showframe(12,25);
    printf("\nPlayer 1, enter your name:");
     fgets(name[0], 30, stdin);
    printf("\nPlayer 2, enter your name:");
     fgets(name[1], 30, stdin);

    printf("\n%s, you take 0",name[0]);
    printf("\n%s, you take X",name[1]); getch();

    clrscr();

    do
    {
       while(!enter)
       {
         if(khbit())
          ch = getch();

           switch(ch)
           {
             case UPARROW : box = navigate(a[3][3], box, player, UPARROW);
             .
             .
             .
           }
       }
       if(quit) break;
       //check if the player wins
       win = checkforwin(a);

     }while(!win)

    if(win)
    { .
      .
    }

    else if(quit)
    {    .
         .
    }

 return 0;
}
}

3.)
  #include<stdio.h>
  void main()
  {
  float m;
  printf("Enter the value of m:\n");
  scanf("%f",&m);
  m/=10;
  printf("Answer is %f",m);
  }

4.)
#include<stdio.h>
void main()
{
int pin;
while(pin!=5135)
{
printf("Enter the Secret pin:");
scanf("%d",&pin);
if(pin!=5135)
printf("Enter Pin is Invalid\n");
else
{
printf("Enter Pin is correct");

}
}

}

5.)
/* write a program to withdrawal a amount
from the bank*/
#include<stdio.h>
void main()
{
char E,H,M;
printf("Press 'E' for English\n'H' for Hindi\n'M' for marathi\n");
scanf("%c%c%c",&E,&H,&M);



}

6.)
/*
 * C Program to Display the ATM Transaction
 */
#include <stdio.h>

unsigned long amount=1000, deposit, withdraw;
int choice, pin, k;
char transaction ='y';

void main()
{
    while (pin != 1520)
    {

        printf("ENTER YOUR SECRET PIN NUMBER:");
        scanf("%d", &pin);
        if (pin != 1520)
        printf("PLEASE ENTER VALID PASSWORD\n");


    }

    do
    {
        printf("********Welcome to ATM Service**************\n");
        printf("1. Check Balance\n");
        printf("2. Withdraw Cash\n");
        printf("3. Deposit Cash\n");
        printf("4. Quit\n");
        printf("******************?**************************?*\n\n");
        printf("Enter your choice: ");
        scanf("%d", &choice);
        switch (choice)
        {
        case 1:
            printf("\n YOUR BALANCE IN Rs : %lu ", amount);
            break;
        case 2:
            printf("\n ENTER THE AMOUNT TO WITHDRAW: ");
            scanf("%lu", &withdraw);
            if (withdraw % 100 != 0)
            {
                printf("\n PLEASE ENTER THE AMOUNT IN MULTIPLES OF 100");
            }
            else if (withdraw >(amount - 500))
            {
                printf("\n INSUFFICENT BALANCE");
            }
            else
            {
                amount = amount - withdraw;
                printf("\n\n PLEASE COLLECT CASH");
                printf("\n YOUR CURRENT BALANCE IS%lu", amount);
            }
            break;
        case 3:
            printf("\n ENTER THE AMOUNT TO DEPOSIT");
            scanf("%lu", &deposit);
                        amount = amount + deposit;
            printf("YOUR BALANCE IS %lu", amount);
            break;
        case 4:
            printf("\n THANK U USING ATM");
            break;
        default:
            printf("\n INVALID CHOICE");
        }
        printf("\n\n\n DO U WISH TO HAVE ANOTHER TRANSCATION?(y/n): \n");
        fflush(stdin);
        scanf("%c", &transaction);
        if (transaction == 'n'|| transaction == 'N')
                    k = 1;
    } while (!k);
    printf("\n\n THANKS FOR USING OUT ATM SERVICE");
}

7.)
#include<stdio.h>
void main()
{unsigned long amount=50000,deposit,withdraw;
 int choice,pin,k;
 char transaction='y';
 while(pin!=2408)
 {
     printf("Enter secret pin:");
     scanf("%d",&pin);
     if(pin!=2408)
        printf("Enter The Valid Pin");

 }
do
{
    printf("**************Welcome To HDFC Bank**************\n");
    printf("1.check Balance\t");
    printf("        2.withdrawal amount\n");
    printf("3.Deposit amount\t");
    printf("4.Quit\n");
    printf("************************************************\n");
    printf("Enter the choice\n");
    scanf("%d",&choice);
    switch(choice)
    {
    case 1:
        printf("Your Balance is Rs:%lu",amount);
        break;
    case 2:
        printf("Enter the Amount Withdraw:");
        scanf("%lu",&withdraw);
        if(withdraw%100!=0)
        {
            printf("\n Enter withdraw anount in multiple of 100");

        }
        else if(withdraw>(amount-1000))
               {

               printf("\n insufficient balance");
        }
        else
               {amount=amount-withdraw;

                printf("\n\n Please Collect Your cash");
                printf("\n Your current balance is %lu",amount);
            }
            break;
    case 3:
        printf("\nEnter the amount Deposit:");
        scanf("%lu",&deposit);
        amount=amount+deposit;
        printf("\nYour balance is %lu",amount);
        break;
    case 4:
        printf("\n Thanking Using ATM service");
        break;
    default:
        printf("\nInvalid choice");

    }
        printf("\n\n\nDo You Want Another Transaction('y or n')?\n");
        fflush(stdin);
        scanf("%c",&transaction);
        if(transaction=='n'||transaction=='N')
            k=2;
}
while(k>5);
    printf("\n Thankyou for using out your atm service ");

    }



8.)
//write a program to find big number
//author :upendra
#include<stdio.h>
void main()
{
int a,b,big;
printf("enter the two numbers:\n");
scanf("%d%d",&a,&b);
big=(a>b)?a:b;
printf("Big number is %d",big);









}
9.)
/*write a program to check birthday
boy name by putting input  of birth year*/
#include<stdio.h>
void main()
{
int year;
printf("Enter the year of a birth:\n");
scanf("%d",&year);
if(year==1971)
    printf("Happy Birthday Dad");
else{
    if(year==1975)
        printf("Happy Birthday Mom");
    else{
        if(year==1992)
            printf("Happy Birthday Bhupendra");
            else{
                if(year==1995)
                    printf("happy Birthday maya");
                else{
                    if(year==2000)
                    printf("Happy birthday Upendra");
                    else{
                        if(year==2005)
                            printf("Happy Birthday nitesh");
                        else
                            {
                                if(year==2009)
                                    printf("happy Birthday chhottu");
                                else
                                    printf("User Input is undefined");
                            }

                    }

                }
            }

    }
}
}

10.)
#include<stdio.h>
void main()
{
int n;
while(n<10)
{
printf("%d\n",n);
n++;
continue;
printf("This will not apper");
}

printf("\n this will appear");
}

No comments:

Python if / else

 Python if / else a1 = int ( input (" Enter the number: \n ")) a2 = int ( input (" Enter the number: \n ")) a3 = int ( i...