August 25, 2018
BY Help Me Our Always0
Comments
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 Programs
C Programs- Switch Case
C Program Simple Calculator Using Switch Case(switch case example)
June 24, 2018
BY Help Me Our Always0
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;
}
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:
Friday, June 22, 2018
C Programs
C Programs- Switch Case
C program Simple Calculator Of Addition or Subtraction using Switch Case
June 22, 2018
BY Help Me Our Always0
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:
C Programs
C Programs- Switch Case
C Switch Case Program (What Do You Want to Drink?) Simple Example for bignners
June 22, 2018
BY Help Me Our Always0
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
Friday, June 15, 2018
Wednesday, June 13, 2018
C Programs
C Programs- Switch Case
C Program To Check Whether it Is Vowel or Constant (Switch Case Example)
June 13, 2018
BY Help Me Our Always0
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:
#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:
C Programs
C Programs- Switch Case
Check Whether The Number Is Positive, Negative Or Zero With Switch Statement
June 13, 2018
BY Help Me Our Always0
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;
}
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;
}
June 13, 2018
BY Help Me Our Always0
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;
}
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;
}