IH8PunkRok Posted January 11, 2010 Report Share Posted January 11, 2010 im trying to make basically a quiz input and answer if correct move to the next question my code is a follows: #include <stdio.h> #include <stdlib.h> int main() { int a ; char b ; do { printf("\nOpposite of 666: "); scanf("%d" , &a); if (a==999) { printf("\nCorrect\n"); printf("Next Question\n"); printf("\n"); do { printf("\nThe 13th letter of the alphabet is:"); scanf("%d" , &; if (b=='m') { printf("\nCorrect\n"); printf("Next Question\n"); printf("\n"); } else { printf("\nIncorrect Learn Your Alphabet, or How to Count... "); } printf("\n"); } while(b=='a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); } else { printf("\nIncorrect"); } printf("\n"); } while (a<1000); } now when enter m as the answer to the 13th letter of the alphabet it goes on a loop of "Incorrect Learn Your Alphabet, or How to Count... "); i cant figure out why it does this anyone know why? btw if it wasnt apparent today was my first day in programming class. im just playing around with the program Quote -Matt2005 Dodge Magnum RTJVC KD-AVX1 2 PPI S580.2 Obsidian Audio ST1 Horn Tweeters PRV 8MB450s Audio Legion 3500.1D 2 RE MT 18s 360 ah LiFePO4 BatterySHCA 2/0 155.2 @ 29 hzKicker CVR 15's buildDD 3512e buildMini T-Line Build(6) 8s BuildNightshade 15s Wall BuildMagnum AB XFL 12s BuildNewest Magnum Build Link to comment Share on other sites More sharing options...
bkolfo4 Posted January 12, 2010 Report Share Posted January 12, 2010 To start with, you have 'm' in the if statement and the while statement, so even if you enter, m, it will ask the question again. Fix that and then tell me what it does. Quote Current system: 1997 Blazer - (4) Customer Fi NEO subs with (8) American Bass Elite 2800.1s Previous systems: 2000 Suburban - (4) BTL 15's and (4) IA 40.1's = 157.7 dB at 37 Hz. 1992 Astro Van - (6) BTL 15's and (6) IA 40.1's = 159.7 dB at 43 Hz. Link to comment Share on other sites More sharing options...
bkolfo4 Posted January 12, 2010 Report Share Posted January 12, 2010 do { printf("\nThe 13th letter of the alphabet is:"); scanf("%d" , &; I think that should be: scanf("%c", &; Quote Current system: 1997 Blazer - (4) Customer Fi NEO subs with (8) American Bass Elite 2800.1s Previous systems: 2000 Suburban - (4) BTL 15's and (4) IA 40.1's = 157.7 dB at 37 Hz. 1992 Astro Van - (6) BTL 15's and (6) IA 40.1's = 159.7 dB at 43 Hz. Link to comment Share on other sites More sharing options...
IH8PunkRok Posted January 12, 2010 Author Report Share Posted January 12, 2010 still the same repeated sequence of failure Quote -Matt2005 Dodge Magnum RTJVC KD-AVX1 2 PPI S580.2 Obsidian Audio ST1 Horn Tweeters PRV 8MB450s Audio Legion 3500.1D 2 RE MT 18s 360 ah LiFePO4 BatterySHCA 2/0 155.2 @ 29 hzKicker CVR 15's buildDD 3512e buildMini T-Line Build(6) 8s BuildNightshade 15s Wall BuildMagnum AB XFL 12s BuildNewest Magnum Build Link to comment Share on other sites More sharing options...
IH8PunkRok Posted January 12, 2010 Author Report Share Posted January 12, 2010 ok well with that %c change i can answer now but after i answer the first question it gives me the second question and an automatic incorrect then brings up the question again for me to answer. then it works Quote -Matt2005 Dodge Magnum RTJVC KD-AVX1 2 PPI S580.2 Obsidian Audio ST1 Horn Tweeters PRV 8MB450s Audio Legion 3500.1D 2 RE MT 18s 360 ah LiFePO4 BatterySHCA 2/0 155.2 @ 29 hzKicker CVR 15's buildDD 3512e buildMini T-Line Build(6) 8s BuildNightshade 15s Wall BuildMagnum AB XFL 12s BuildNewest Magnum Build Link to comment Share on other sites More sharing options...
bkolfo4 Posted January 12, 2010 Report Share Posted January 12, 2010 Can you cut and paste what happens when you run the program? Been a long time since I have programmed, and I learned C++. Quote Current system: 1997 Blazer - (4) Customer Fi NEO subs with (8) American Bass Elite 2800.1s Previous systems: 2000 Suburban - (4) BTL 15's and (4) IA 40.1's = 157.7 dB at 37 Hz. 1992 Astro Van - (6) BTL 15's and (6) IA 40.1's = 159.7 dB at 43 Hz. Link to comment Share on other sites More sharing options...
IH8PunkRok Posted January 12, 2010 Author Report Share Posted January 12, 2010 all i did was type in 999 and hit enter that is what came up Quote -Matt2005 Dodge Magnum RTJVC KD-AVX1 2 PPI S580.2 Obsidian Audio ST1 Horn Tweeters PRV 8MB450s Audio Legion 3500.1D 2 RE MT 18s 360 ah LiFePO4 BatterySHCA 2/0 155.2 @ 29 hzKicker CVR 15's buildDD 3512e buildMini T-Line Build(6) 8s BuildNightshade 15s Wall BuildMagnum AB XFL 12s BuildNewest Magnum Build Link to comment Share on other sites More sharing options...
bkolfo4 Posted January 12, 2010 Report Share Posted January 12, 2010 If you type m at that point, what does it do? Quote Current system: 1997 Blazer - (4) Customer Fi NEO subs with (8) American Bass Elite 2800.1s Previous systems: 2000 Suburban - (4) BTL 15's and (4) IA 40.1's = 157.7 dB at 37 Hz. 1992 Astro Van - (6) BTL 15's and (6) IA 40.1's = 159.7 dB at 43 Hz. Link to comment Share on other sites More sharing options...
IH8PunkRok Posted January 12, 2010 Author Report Share Posted January 12, 2010 this which is basically right but with one minor error Quote -Matt2005 Dodge Magnum RTJVC KD-AVX1 2 PPI S580.2 Obsidian Audio ST1 Horn Tweeters PRV 8MB450s Audio Legion 3500.1D 2 RE MT 18s 360 ah LiFePO4 BatterySHCA 2/0 155.2 @ 29 hzKicker CVR 15's buildDD 3512e buildMini T-Line Build(6) 8s BuildNightshade 15s Wall BuildMagnum AB XFL 12s BuildNewest Magnum Build Link to comment Share on other sites More sharing options...
bkolfo4 Posted January 12, 2010 Report Share Posted January 12, 2010 It could be that you have a new line character in the buffer and it is reading it as the character the first time through. . . What happens if you type an m at that point, and what happens if you type another character at that point? Also note you can say if b != 'm' in that while statement instead of typing == and all of the letters of the alphabet. Brian Quote Current system: 1997 Blazer - (4) Customer Fi NEO subs with (8) American Bass Elite 2800.1s Previous systems: 2000 Suburban - (4) BTL 15's and (4) IA 40.1's = 157.7 dB at 37 Hz. 1992 Astro Van - (6) BTL 15's and (6) IA 40.1's = 159.7 dB at 43 Hz. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.