Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/gdclan/grossdachshund.com/forums/includes/bbcode.php on line 483
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3824: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3826: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3827: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3828: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
Gross Dachshund Field Comms • View topic - C programming

Skip to content


C programming

all things techy
you never know, might get an answer

Moderator: Edpow1


C programming

Postby Gapiro » Thu Oct 06, 2005 12:14 pm

Can you have a look at this code? it works for the first and last question but it doesn't do the second question for somet reason, just goes past without taking scanf
Code: Select all
#include <stdlib.h>
#include <stdio.h>
main()
{
int score1,score2,score3,scoret; /* define variables*/
char q1;
char y;
char q2;
char q3;
  printf ("\n This is a quiz to practise my programming and to check your intelligence")
  printf("\n You will be asked a series of questions and the answers will be in the form of y/n standing for yes or no")
  printf("\n First question: \n Is the eiffel tower is 986 feet tall?"); /*Intro and first Question*/
  scanf("%c",&q1);/*take input*/
  if (q1=='y') {printf ("Well done you are correct\n");
  score1=1;/*check if correct and make score 1*/
}
else {printf ("bad luck, it is in fact that high\n");
score1=0;/*if incorrect, make score for question 0*/
}

   printf("\n Question 2: \n Does the river trent flow through nottingham?\n");/*ask second question*/
scanf("%c",&q2);
if (q2=='y'){printf ("Well done you are correct\n");
score2=1;/*check if correct and make score 1*/
}
else{printf("bad luck. It does actually flow through nottingham\n");
score2=0;/*if incorrect, make score for question 0*/
}

printf("\n Question 3: \n Is Stockholm the capital of Denmark ?\n");
scanf("%c",&q3);
if (q3=='n'){printf ("Well done you are correct\n");
  score3=1;/*check if correct and make score 1*/
}
else{printf("Sorry you are wrong, it is in fact Copenhagen \n");
score3=0;/*if incorrect, make score for question 0*/
}
scoret=score1+score2+score3;/*add total score and store in scoret*/
printf ("\n Congratulations on finishing the quiz, your score is %d\n",scoret); /*display score*/
return 0;
}
User avatar
Gapiro
Herr General
 
Posts: 3152
Joined: Thu Apr 10, 2003 4:01 pm
Location: United Kingdom


Postby Gapiro » Thu Oct 06, 2005 12:18 pm

Image
User avatar
Gapiro
Herr General
 
Posts: 3152
Joined: Thu Apr 10, 2003 4:01 pm
Location: United Kingdom


Postby PIRANHA » Thu Oct 06, 2005 5:33 pm

Sorry Gap - only done VB, Pascal and a little Java.
User avatar
PIRANHA
Party Secretary
 
Posts: 399
Joined: Wed Mar 30, 2005 9:58 pm
Location: United Kingdom


Postby bruhv » Thu Oct 06, 2005 6:38 pm

i just had a quick look thru it and can't see anything obvious, sorry
User avatar
bruhv
Oberkommando des Heeres
Oberkommando des Heeres
 
Posts: 154
Joined: Thu Mar 20, 2003 2:04 pm
Location: FOAD


Return to Board index

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 1 guest