Check whether a number is even or odd

#include<stdio.h&t;

int main()
{
int num;
printf(“Enter any number :: “);
scanf(“%d”,&num);

if(num%2 == 0)
printf(“%d is Even Number”,num);
else
printf(“%d is odd Number”,num);

return 0;
}

Output::
Enter any number ::
11
11 is odd Number

or

Enter any number ::
10
10 is Even Number

Advertisements

Swap two numbers – XOR Operator

#include
/*
Swap two numbers @kodingkeys@keycomputer
*/
int main()
{
int num1, num2;

printf(“Enter two numbers to swap ::”) ;
scanf(“%d%d”,&num1, &num2);

num1= num1 ^ num2;
num2 = num1 ^ num2;
num1 = num1 ^ num2;

printf(“Swapped numbers %d – %d”,num1, num2) ;

return 0;
}

Sizeof Function

#include<stdio.h>
/*
Sizeof function @kodingkeys@keycomputer
*/
int main()
{
int i;
float f;
double d;
char c;

// Sizeof operator is used to evaluate the size of a variable
printf(“Size of int: %ld bytes\n”,sizeof(i));
printf(“Size of float: %ld bytes\n”,sizeof(f));
printf(“Size of double: %ld bytes\n”,sizeof(d));
printf(“Size of char: %ld byte\n”,sizeof(c));

return 0;
}

Output:
Size of int: 4 bytes
Size of float: 4 bytes
Size of double: 8 bytes
Size of char: 1 byte