Smart Lab Helping Forum

Members Login
Username 
 
Password 
    Remember Me  
Post Info TOPIC: Questions for Fundamentals of Programming Course


Veteran Member

Status: Offline
Posts: 39
Date:
Questions for Fundamentals of Programming Course
Permalink  
 


If you have any questions related to the Fundamentals of Programing course, ask on this forum. The TA's will reply here.

Thanks,
Shamyl

__________________


Newbie

Status: Offline
Posts: 3
Date:
Permalink  
 

Assalam O Alaikum Sir,

Kindly help me to figure out the solution for this problem...The compiler isn't showing any error or warning still the program is not working properly..... Here is the code for this program. This program was made to calculate the fast food bill using switches...

#include

void main()

{
int choice , total = 0,x ;
int ffood;


printf("\t\t\t\tWELCOME TO KFC\n\n");
printf("\t\t\t\tMAIN MENU\n\n");
printf("\t\t\tPress 1 for fast food menu\n");
printf("\t\t\tPress 2 to quit\n ");
scanf("%d",&choice);





switch (choice)

{ case 1:
printf("\t\t\tPLEASE GIVE YOU CHOICE\n\n");
printf("Press 4 for shami burgers = 100RS\n");
printf("Press 5 for chicken pizza = 700RS\n");
printf("Press 6 for drinks = 10RS\n");
printf("Press 2 to exit");
scanf("%c",&ffood);

switch (ffood)
{ case 4:
total = total + 100;
printf("\t\t\t\nYou have bought a shami burger worth 100RS.Your current bill is %d", total);
break;

case 5:
total = total + 700;
printf("\t\t\t\nYou have bought a chicken pizza worth 700RS.Your current bill is %d", total);
break;

case 6:
total = total + 10;
printf("\t\t\t\nYou have bought a soft drink worth 10RS.Your current bill is %d", total);
break;

default :
break;


}
}
}



















__________________
Hsn


Veteran Member

Status: Offline
Posts: 39
Date:
Permalink  
 

Walaikum Salam Hsn,

 

     The problem in your code is at the second scanf function where you are trying to store a character in an integer.

scanf("%c",&ffood);

You have declared ffood as integer but trying to scanf in a character using %c. Change it to %d and your problem is solved.

scanf("%d",&ffood);

Shamyl



__________________


Newbie

Status: Offline
Posts: 1
Date:
Permalink  
 

confuse

AOA SIR... My marks of LAb one have Not been enterEd.... [=S]
 



__________________


Newbie

Status: Offline
Posts: 3
Date:
Permalink  
 

AoA,

My name is Sarmad Shakeel. I have problem in grade sheet which is shown in the class. In that grade sheet my marks of 1st lab task are not entered.

Kindly check it out.

Regards
Sarmad Shakeel
BE-Civil Engineering,
NUST institute of Civil Engineering,
Islamabad, Pakistan.


__________________
Sarmad Shakeel BE-Civil Engineering, NUST institute of Civil Engineering, Islamabad, Pakistan.


Member

Status: Offline
Posts: 5
Date:
Permalink  
 

Slam Sir,

can i repeat and exit the program with while loop using characters instead of integers.no



__________________


Newbie

Status: Offline
Posts: 4
Date:
Permalink  
 

WSalam,
yes u can do this also by characters .

Sample code

char ch='y';
while(ch!='n')
{
...
....
..
..
.
}



__________________


Member

Status: Offline
Posts: 5
Date:
Permalink  
 

ThanX



__________________
Page 1 of 1  sorted by
 
Quick Reply

Please log in to post quick replies.



Create your own FREE Forum
Report Abuse
Powered by ActiveBoard