473,383 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

how to use mathemathical symbol in switch(URGENT)

3
i have a problem to enter the input A+ or B+ in switch case
any body can help to solve my problem
program like this

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. int main()
  3. { //start program
  4.     int part,sol,com,cir,mat,wav,lan,anw;
  5.     float no1,no2,no3,no4,no5,no6,gpa,cgpa,res,total=17;
  6.     char c1,c2,c3,c4,c5,c6,q;
  7.       int loop=1;
  8.     while (loop==1)
  9.     {// start while
  10.     printf("Enter part of sem: ");
  11.     scanf("%d",&part);
  12.  
  13.     if (part==4)//start if
  14.     {
  15.         printf("Enter grade for the following subject\n");
  16.  
  17.         printf("Solid State: ");
  18.         scanf("%c",&c1);
  19.         sol=getchar();
  20.         switch (sol) { //start switch1
  21.             case 'A' :
  22.             case 'a' :
  23.             case 'A+':
  24.             case 'a+':no1=4.00*3.00;
  25.             break;
  26.  
  27.             case 'a-':
  28.             case 'A-':no1=3.67*3.00;
  29.             break;
  30.  
  31.             case 'B+':
  32.             case 'b+':    no1=3.33*3.00;
  33.             break;
  34.  
  35.             case 'B':
  36.             case 'b':    no1=3.00*3.00;
  37.             break;
  38.  
  39.             case 'B-':
  40.             case 'b-':    no1=2.67*3.00;
  41.             break;
  42.  
  43.             case 'C+':
  44.             case 'c+': no1=2.33*3.00;
  45.             break;
  46.  
  47.             case 'C':
  48.             case 'c': no1=2.00*3.00;
  49.             break;
  50.  
  51.             case 'C-':
  52.             case 'c-': no1=1.67*3.00;
  53.             break;
  54.  
  55.             case 'D+':
  56.             case 'd+': no1=1.33*3.00;
  57.             break;
  58.  
  59.             case 'D':
  60.             case 'd': no1=1.00*3.00;
  61.             break;
  62.  
  63.             default: printf("wrong input");
  64.             break;
  65.             }// end switch1
  66.  
  67. //output program
  68.     printf("Solid State:\t%c\n%.2f",sol,no1);
  69.  
  70. return 0;
  71.  
  72. } // program terminated
Mar 27 '07 #1
1 1182
horace1
1,510 Expert 1GB
the case values should be integer constants (ints, chars, etc). e.g.
Expand|Select|Wrap|Line Numbers
  1.         switch (sol) { //start switch1
  2.             case '+':no1=4.00+3.00;
  3.             break;
  4.             case '*':no1=4.00*3.00;
  5.             break;
  6.  
Mar 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: sunil | last post by:
Hi, We have lot of c and fortran archive libraries that have complex dependencies. We have different server tasks that use some of these libraries. We have developed a tool inhouse that links...
3
by: Rob | last post by:
I have a form - when you click the submit button, it appends a variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable) It also opens a new page. Now, that some_dynamic_variable is...
1
by: Joseph Narissi | last post by:
Hello, For my current project I need to incorporate some legacy C code with my c++.NET app. I have my project setup to use an additional INCLUDE directory, pointed to the VS6 include directory....
2
by: sweety | last post by:
Dear All, I need an urgent help on following. How i can print the ® symbol in to the C file. I stored in a Wchar so, how i can read or print this.. Quick response would be great !!! if...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
3
by: pb | last post by:
If I have a currency code like "USD" or "EUR", how do I format a string from a decimal value that would contain the correct currency symbol? for example, if I have "USD" and 345.45, I want to...
6
by: phnimx | last post by:
I'm attempting to migrate a predominately MFC application that I've just inherited from Visual Studio.NET 2003 to Visual Studio 2005. I've managed to clean up a myriad of compile and link errors...
7
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I am attempting to fetch data from an external process. It seems to work OK with regular arguments, but not with switch arguments. Here is an example of a failure:...
1
by: ananthaisin | last post by:
Hi, This is the query i am trying to build I have attached the same in the file.... while running its throwing an error ........ NVL((SELECT USAGEMODE FROM KKTYPEMAST_AP B WHERE...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.