HelpMeOutAlways: C Programs- Switch Case
Showing posts with label C Programs- Switch Case. Show all posts
Showing posts with label C Programs- Switch Case. 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:
Switch Program To Print A Week (example switch ) In C
June 13, 20180 Comments
#include<stdio.h>
main()
{
int week;
printf("Enter any Number To Print Week day (1-7):\n");
scanf("%d",&week);
switch(week)
{
case 1: printf("Its Monday");
break;
case 2: printf("Its Tuesday");
break;
case 3: printf("Its Wednesday");
break;
case 4: printf("Its Thursday");
break;
case 5: printf("Its Friday");
break;
case 6: printf("Its Saturday");
break;
case 7: printf("Its Sunday");
break;
default:
printf("its Not A week");

}
return 0;
}

OUTPUT


Reading Time:

@way2themes