0% found this document useful (0 votes)
3 views2 pages

C Programming Examples and Outputs

The document provides examples of basic C programming, including a Hello World program, a simple addition program, and a pointer program. Each example includes the code and expected output. These examples demonstrate fundamental concepts in C programming such as output, arithmetic operations, and pointer usage.

Uploaded by

kdhakal3210
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

C Programming Examples and Outputs

The document provides examples of basic C programming, including a Hello World program, a simple addition program, and a pointer program. Each example includes the code and expected output. These examples demonstrate fundamental concepts in C programming such as output, arithmetic operations, and pointer usage.

Uploaded by

kdhakal3210
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Programming Examples

1. Basic Hello World Program


#include <stdio.h>

int main() {
printf("Hello, World!\n");
return 0;
}
Output:
Hello, World!

2. Simple Addition Program


#include <stdio.h>

int main() {
int a = 5, b = 10;
int sum = a + b;
printf("Sum: %d\n", sum);
return 0;
}
Output:
Sum: 15

3. Simple Pointer Program


#include <stdio.h>

int main() {
int num = 20;
int *ptr = &num;
printf("Value of num: %d\n", num);
printf("Address of num: %p\n", &num);
printf("Pointer value: %p\n", ptr);
printf("Value through pointer: %d\n", *ptr);
return 0;
}
Output (example output, address values may vary):
Value of num: 20
Address of num: 0x7ffee7b4a6f4
Pointer value: 0x7ffee7b4a6f4
Value through pointer: 20

You might also like