C Programming Tutorial - 17 - Making Decisions Using if Statements

+1 oscar labrador · March 7, 2015
hello im currently stuck in this tutorial on youtube. "C Programming Tutorial - 17 - Making Decisions Using if Statements"

i wrote the exact same code on the video but everytime i click build and run using codeblock ide, an error window pops us and says "A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."

this is the exact same code i wrote just like the one on the video tutorial. After i enter the age using the scanf, the error pops up.

/images/forum/upload/2015-03-07/da8ee853024d7e4564048a3d0142f846.png

Post a Reply

Replies

Oldest  Newest  Rating
0 c student · March 7, 2015
works fine for me: http://ideone.com/Hiw2eF

what was your input?  what was the error?
0 oscar labrador · March 7, 2015
this is what happens every time i input the age. 

/images/forum/upload/2015-03-07/d16747b966c7b3fafbd46b50d48ced04.jpg 
0 Ebarak Hossain · March 7, 2015
A slightly different way of doing the same thing is given below:

#include <stdio.h>

int main(void)
{
    int age;

    printf("How old are you? \n");
    scanf("%d", &age);

    if (age >= 18){
        printf("You may visit this website.");
    }else {
        printf("Nothing to see here.");
    }
return 0;
}
0 oscar labrador · March 7, 2015
i finally fixed it. it was the the placement of quotation mark on scanf (2nd screenshot). But my first screenshot was correct(which is weird because it didn't work). But oh well it works now. thanks for you response!
  • 1

C

107,155 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator