HelpMeOutAlways: C Programs
Showing posts with label C Programs. Show all posts
Showing posts with label C Programs. Show all posts

Saturday, August 25, 2018

Sunday, June 24, 2018

C Program Simple Calculator Using Switch Case(switch case example)
June 24, 20180 Comments
#include<stdio.h>
main ()
{
  int menu, add, sub, mult, quit, num1, num2;
  float dvd,Num1,Num2;// Here Num1 and Num2 is declared for Division operaion
  printf ("=======================================\n");
  printf ("Simple Calculator for Addition And Subtraction");
  printf ("=======================================\n");
  printf ("1.Add\n");
  printf ("2.Sub\n");
  printf ("3.Multiplication\n");
  printf ("4.Division\n");
  printf ("5.Quit\n");
  printf ("Please Select what do you want?\n");
  scanf ("%d", &menu);
  switch (menu)
    {
    case 1:
      printf ("Enter Two Numbers:\n");
      scanf ("%d %d", &num1, &num2);
      add = num1 + num2;
      printf ("Addition =%d", add);
      break;

    case 2:
      printf ("Enter Two Numbers:\n");
      scanf ("%d %d", &num1, &num2);
      sub = num1 - num2;
      printf ("Subtraction =%d\n", sub);
      break;
    case 3:
      printf ("Enter Two Numbers:\n");
      scanf ("%d %d", &num1, &num2);
      mult = num1 * num2;
      printf ("Multiplication =%d\n", mult);
      break;
    case 4:
      printf ("Enter Two Numbers:\n");
      scanf ("%f %f", &Num1, &Num2);
      dvd = Num1 / Num2;
      printf ("Division =%.2f", dvd);
      break;
    case 5:
      printf ("Program terminated!");
      break;
    default:
      printf ("Wrong Input!");}
      return 0;
    }

Output:

c program simple calculator using switch case

c program simple calculator using switch case

c program simple calculator using switch case

c program simple calculator using switch case

Reading Time:

Friday, June 22, 2018

C program Simple Calculator Of Addition or Subtraction using Switch Case
June 22, 20180 Comments

Source Code


#include<stdio.h>

int
main ()
{
  int menu, add, sub, quit, num1, num2;
  printf ("======================================================\n");
  printf ("Simple Calculator for Addition And Subtraction");
  printf ("======================================================\n");
  printf ("1.Add\n");
  printf ("2.Sub\n");
  printf ("3.Quit\n");
  printf ("Please Select what do you want?\n");
  scanf ("%d", &menu);


  switch (menu)
    {
    case 1:
      printf ("Enter Two Numbers:\n");
      scanf ("%d %d", &num1, &num2);
      add = num1 + num2;
      printf ("Addition =%d", add);
     
      break;
     
    case 2:
      printf ("Enter Two Numbers:\n");
      scanf ("%d %d", &num1, &num2);
      sub = num1 - num2;
      printf ("Subtraction =%d\n", sub);
     
      break;
     
      case 3:
            printf("Program terminated!");
            break;

    default:
      printf ("Wrong Input!");
    }
  return 0;
}

Output:

simple calculator for addition and subtraction

simple calculator program for add and sub

simple calculator for add and sub program c


Reading Time:
C Switch Case Program (What Do You Want to Drink?) Simple Example for bignners
June 22, 20180 Comments

Source Code

#include<stdio.h>

main ()
{
  int drink;
  printf ("Hello!Sir\n");
  printf ("What would you like to drink?\n");
  printf ("1.Tea\n");
  printf ("2. Coffe\n");
  printf ("Please Select (1/2):\n");
  scanf ("%d", &drink);

  switch (drink)
    {
    case 1:
      printf ("Tea! ok Sir, i will be right back ", drink);
      break;
    case 2:
      printf ("Coffe! ok Sir, i will be right back ", drink);
      break;
    }
  return 0;
}

Output

switch simple example

switch simple example


Reading Time:

Friday, June 15, 2018

C Program To Check The Number Whether It Is Even or Odd( Switch Case)
June 15, 20180 Comments
#include<stdio.h>
main()
{
int num;
printf("Enter Any Integer\n");
scanf("%d",&num);
switch(num%2)
{
case 0:
printf("%d is Even Number",num);
break;
case 1:
printf("%d is Odd Number",num);
break;

}
return 0;

}


Output:



switch case example

switch case exercise

Reading Time:
C Program To Check Whether It Is Leap Year Or Common Year (Switch Case)
June 15, 20180 Comments
// C program to check whether it is leap or common year
#include<stdio.h>
main()
{
int year;
printf("Enter Year:\n");
scanf("%d",&year);
switch(num%4==0&&num%100!=0||num%400==0)
{
case 1:
printf("Leap Year");
break;

default:
printf("common year");
}
return 0;
}

Output



switch case example

switch case example

switch case example

Reading Time:

Wednesday, June 13, 2018

C Program To Check Whether it Is Vowel or Constant (Switch Case Example)
June 13, 20180 Comments
//Write a C program TO chEck WheatHer It iS VoWel Or CoNsTant
#include<stdio.h>

main()
{
char ch;
printf("Enter any character:\n");
scanf("%c",&ch);
switch(ch)
{
case 'a': case 'A' :
printf("Its VOwel Baby!");
break;
case 'e': case 'E' :
printf("Its VOwel Baby!");
break;
case 'i': case 'I' :
printf("Its VOwel Baby!");
break;
case 'o': case 'O' :
printf("Its VOwel Baby!");
break;
case 'u': case 'U' :
printf("Its VOwel Baby!");
break;
default:
printf("Its Constant Baby!");
}
return 0;

}

Output:



Reading Time:
Check Whether The Number Is Positive, Negative Or Zero With Switch Statement
June 13, 20180 Comments
#include<stdio.h>
main()
{
int num;
printf("Enter any Number To Check It is Positive or Negative:\n");
scanf("%d",&num);
switch(num>0)
{
case 1:
printf("%d is positive number",num);
break;
case 0:
switch(num<0)
{
case 1:
printf("%d is negative number",num);
break;

case 0:
printf("%d is zero",num);
break;

}
break;

}

return 0;
}

switch example In C

switch case example

Switch Case Example In C

Reading Time:

Sunday, June 10, 2018

ATM Program In C language (SHows Notes of 5000,1000,500,100,50 and 10)
June 10, 20181 Comments
Here you can find the source code of ATM Machine Program Transaction In C language by HelpMeOutAlways.

ATM Machine Program Source Code

 #include <stdio.h>

unsigned long int amount = 50000, depositS;
//Number Of Notes Available in The ATM Machine, down below statements
unsigned long int FiveThousandNotes = 50;

unsigned long int ThousandNotes = 50;

unsigned long int FiveHundredNotes = 50;

unsigned long int OneHundredNotes = 50;

unsigned long int TenNotes = 50;

unsigned long int fiftyNotes = 50;

unsigned long int withdrawAmount;

unsigned long int totalMoney;

unsigned long int fivethousand = 0, thousand = 0, fiveHundred =
  0, oneHundred = 0, fifty = 0, ten = 0;

int choice, pin, k;

char transaction = 'y';


main ()
{

  while (pin != 1520)

    {

      printf ("ENTER YOUR FOUR DIGIT PIN NUM:"); //User will Enter His Four Digit Pin Code

      scanf ("%d", &pin); // REads OutPut

      if (pin != 1520) /// IF It is Not The COrrect Pin

printf ("WRONG PASSWORD! TRY AGAIN\n");

    }

  do // It Will Once Print All the Statements Given Below

    {

      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: "); // Chooes One of The Option

      scanf ("%d", &choice); //Read The input

      switch (choice)

{

case 1: // Check Balance

  printf ("\n YOUR BALANCE IN Rs : %lu ", amount);

  break;

case 2: // To widthdraw Money

  printf ("Enter the amount in multiple of 10:"); // Enter money more than 100 in multiples

  scanf ("%lu", &withdrawAmount);

  if (withdrawAmount < amount)

    {

      amount = amount - withdrawAmount;

      printf ("\nYour balance is Rs: %lu \n", amount);

    }

  if (withdrawAmount % 10 != 0) // If not in Multip
    {

      printf ("Invalid amount\n");

      return 0;

    }

  totalMoney =
    ThousandNotes * 1000 + FiveHundredNotes * 500 +
    OneHundredNotes * 100 + fiftyNotes * 50 + TenNotes * 10;

  if (withdrawAmount > totalMoney)
    {

      printf ("Sorry,Insufficient money\n");

      return 0;

    }

  fivethousand = withdrawAmount / 5000;

  if (fivethousand > FiveThousandNotes)

    fivethousand = FiveThousandNotes;

  withdrawAmount = withdrawAmount - fivethousand * 5000;



  thousand = withdrawAmount / 1000;

  if (thousand > ThousandNotes)

    thousand = ThousandNotes;

  withdrawAmount = withdrawAmount - thousand * 1000;



  fiveHundred = withdrawAmount / 500;

  if (fiveHundred > FiveHundredNotes)

    fiveHundred = FiveHundredNotes;

  withdrawAmount = withdrawAmount - fiveHundred * 500;



        if (withdrawAmount > 0)
     
        oneHundred=withdrawAmount/100;
     
  if (oneHundred > OneHundredNotes)

    oneHundred = OneHundredNotes;

  withdrawAmount = withdrawAmount - oneHundred * 100;


        if (withdrawAmount > 0)
     
        fifty=withdrawAmount/50;
     
  if (fifty > fiftyNotes)

    fifty = fiftyNotes;

  withdrawAmount = withdrawAmount - fifty * 50;


     
  if (withdrawAmount > 0)

    ten = withdrawAmount / 10;

  if (ten > TenNotes)

    ten = TenNotes;

  withdrawAmount = withdrawAmount - ten * 10;



  printf ("Total 5000 note:%lu\n", fivethousand);

  printf ("Total 1000 note:%lu\n", thousand);

  printf ("Total 500 note:%lu\n", fiveHundred);

  printf ("Total 100 note:%lu\n", oneHundred);

  printf ("Total 50 notes:%lu\n", fifty);

  printf ("Total  10 notes:%lu\n", ten);


  break;

case 3:

  printf ("\n ENTER THE AMOUNT TO DEPOSIT:");

  scanf ("%lu", &depositS);

  amount = amount + depositS;

  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); //It make a wide Space Between the Line

      scanf ("%c", &transaction);

      if (transaction == 'n' || transaction == 'N')

k = 1;

    }
  while (!k);

  printf ("\n\n THANKS FOR USING OUT ATM SERVICE");

  return 0;
}




Outputs


atm machine program in c language

atm machine program in c language

atm machine program in c language

atm machine program in c language


I hope that this ATM Program In C language has helped you to understand how ATM Machine works.
Reading Time:

Sunday, June 3, 2018

C Program To Find Maximum Among Three Numbers(Integers) Using Nested if-else Statement
June 03, 20180 Comments
//find maximum number among three integers
#include<stdio.h>
main()
{
int n1,n2,n3,max; //Declaration of variables
printf("Enter any three integers:\n");
scanf("%d%d%d",&n1,&n2,&n3);// Read three numbers from user
if(n1>n2) //let(condition 1)
{
if(n1>n3)//let (condition 2)
{

max=n1;} //if condition 1 and 2 are true then n1 is maximum
else{
max=n3; //if condition 1 is true but condition 2 is not true then max=n3
}
}
else
{
if(n2>n3){//let (condition3) if condition1 and condition2 are both false then condition 3 will execute i.e max=2

max=n2;}
else
{max=n3;//if conditon 1,2,3 are false then max=n3
}
}
printf("maximun from above three integers is=%d",max);//Show the maximum number to the outside world
return 0;
}
nested if- else

Reading Time:

Tuesday, May 29, 2018

C Multiplication Program Input from User
May 29, 20180 Comments
Source Code

// Simple multiplication Program
#include<stdio.h>
main()
{
int n,i;
printf("Enter any Integer Num:");
scanf("%d",&n);
for(i=1;i<=10;i++)
{

printf("%d * %d= %d\n",n,i,n*i);

}

return 0;

}

Output of Program
Output of c multiplication program



Reading Time:
Factorial C Program Input From User
May 29, 20180 Comments
//Factorial program
#include<stdio.h>
main()
{
int num,fact=1,i;
printf("Enter a number to check its factorial:\n");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
fact=fact*i;

}
printf("fact of %d is=%d",num,fact);
return 0;}

OUTPUT
C program output factorial


Reading Time:
C Multiplication Table Starting and Ending Point
May 29, 20180 Comments
//Multiplication Table oF desite

#include <stdio.h>
int main()
{
    int n, i,start, range;

    printf("Enter an integer: ");
    scanf("%d",&n);

    printf("Enter the Start: ");
    scanf("%d", &start);
    printf("Enter the range: ");
    scanf("%d", &range);

    for(i= start; i <= range; ++i)
    {
        printf("%d * %d = %d \n", n, i, n*i);
    }

    return 0;
}

Output Of Program
output of c table program

Reading Time:

@way2themes