October 22, 2024
Chicago 12, Melborne City, USA
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

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video