OiO.lk Blog C# How to print a value stored in a variable in C
C#

How to print a value stored in a variable in C


How to print a value stored in a variable in C.
I am new in C and I have a little bit of experience in python.
In python if we take num = 30 and if we do print(num). the output is 30.
I want to do the same thing in c but if i write int num = 30; and printf(num) I get a error "Segmentation fault (core dumped)".
I want to Know how to print the value stored in num variable.

#include <stdio.h>

int main() 
{
    int a = 30;
    printf(a); // it gives "Segmentation fault (core dumped)" error
    return 0;
}



You need to sign in to view this answers

Exit mobile version