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.


Post a Reply


Oldest  Newest  Rating
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!
0 oscar labrador · March 7, 2015
this is what happens every time i input the age. 

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

what was your input?  what was the error?
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator