Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views4 pages

Task 1-4

The document contains multiple C programs demonstrating basic input and output operations. It includes examples for printing messages, checking if a number is negative, determining if an integer is odd or even, and comparing two integers. Each program prompts the user for input and displays the corresponding result based on the logic implemented.

Uploaded by

you00737axa
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)
6 views4 pages

Task 1-4

The document contains multiple C programs demonstrating basic input and output operations. It includes examples for printing messages, checking if a number is negative, determining if an integer is odd or even, and comparing two integers. Each program prompts the user for input and displays the corresponding result based on the logic implemented.

Uploaded by

you00737axa
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/ 4

#include <stdio.

h>
#include <stdlib.h>

int main()
{
printf("hello");
//1 printf("Hello world\b \n");// backspace
//2printf("Hello\tclass \n");// tab
//3int i= NULL;
//3printf("%d\n", i);
return 0;
}
// Program to display a number if it is negative

#include <stdio.h>
int main() {
int number;

printf("Enter an integer: ");


scanf("%d", &number);

// true if number is less than 0


if (number < 0) {
printf("You entered %d.\n", number);
}

printf("The if statement is easy.");

return 0;
}
// Check whether an integer is odd or even

#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
scanf("%d", &number);

// True if the remainder is 0


if (number%2 == 0) {
printf("%d is an even integer.",number);
}
else {
printf("%d is an odd integer.",number);
}

return 0;
}
// Program to relate two integers using =, > or < symbol

#include <stdio.h>
int main() {
int number1, number2;
printf("Enter two integers: ");
scanf("%d %d", &number1, &number2);

//checks if the two integers are equal.


if(number1 == number2) {
printf("Result: %d = %d",number1,number2);
}

//checks if number1 is greater than number2.


else if (number1 > number2) {
printf("Result: %d > %d", number1, number2);
}

//checks if both test expressions are false


else {
printf("Result: %d < %d",number1, number2);
}

return 0;
}

You might also like