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

C Programs

The document contains multiple C programs demonstrating basic input and output functions. It includes examples for printing 'Hello World', taking an integer input, adding two integers, and checking if a number is positive, negative, or zero. Each program is self-contained with a main function and relevant comments.

Uploaded by

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

C Programs

The document contains multiple C programs demonstrating basic input and output functions. It includes examples for printing 'Hello World', taking an integer input, adding two integers, and checking if a number is positive, negative, or zero. Each program is self-contained with a main function and relevant comments.

Uploaded by

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

// Header file for input output functions

#include <stdio.h>

// Main function: entry point for execution


int main() {

// Writing print statement to print hello world


printf("Hello World");

return 0;
}

// C program to take an integer


// as input and print it
#include <stdio.h>

// Driver code
int main()
{
// Declare the variables
int num;

// Input the integer


printf("Enter the integer: ");
scanf("%d", &num);

// Display the integer


printf("Entered integer is: %d", num);

return 0;
}

// C program to add two numbers


#include <stdio.h>

int main() {
int a, b, sum = 0;

// Read two numbers from the user


printf("Enter two integers: ");
scanf("%d %d", &a, &b);

// Calculate the addition of a and b


// using '+' operator
sum = a + b;
printf("Sum: %d", sum);

return 0;
}

// C Program to check if a number is positive, negative,


// or zero using simple conditional checks
#include <stdio.h>

int main() {
int N = 10;
// Check if the number is zero
if (N == 0) {
printf("Zeri\n");
}
// Check if the number is less than zero
else if (N < 0) {
printf("Negative\n");
}
// If neither, the number is positive
else {
printf("Positive\n");
}
return 0;
}

You might also like