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

Basic C Programs Explained

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

Basic C Programs Explained

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
You are on page 1/ 2

Basic C Programs with Explanations and Output

1. C Hello World Program

Code:

#include <stdio.h>

int main() {

printf("Hello, World!");

return 0;

Explanation:

This program prints 'Hello, World!'. It uses printf() from stdio.h, and main() is the entry point.

Sample Output:

Hello, World!

2. C Program to Print Your Own Name

Code:

#include <stdio.h>

int main() {

printf("My name is Preethi.");

return 0;

Explanation:

Replaces Hello World with your name. You can change the string to print your own name.

Sample Output:

My name is Preethi.

3. C Program to Print an Integer Entered By the User

Code:

#include <stdio.h>

int main() {

int number;
printf("Enter an integer: ");

scanf("%d", &number);

printf("You entered: %d\n", number);

return 0;

Explanation:

Takes an integer input from user using scanf() and prints it back using printf().

Sample Output:

Enter an integer: 5

You entered: 5

You might also like