Skip to content

Instantly share code, notes, and snippets.

View scratchyourbrain's full-sized avatar

scratchyourbrain

View GitHub Profile
@scratchyourbrain
scratchyourbrain / C Program to Check Whether a Number is Even or Odd
Created December 15, 2014 11:20
C Program to Check Whether a Number is Even or Odd
#include <stdio.h>
int main()
{
int num;
printf("Enter an integer you want to check: ");
scanf("%d",&num);
if((num%2)==0) /* Checking whether remainder is 0 or not. */
printf("%d is even.",num);
else
printf("%d is odd.",num);
@scratchyourbrain
scratchyourbrain / C Program to swap two numbers
Created December 14, 2014 12:33
C Program to swap two numbers
#include <stdio.h>
int main()
{
int a, b, temp;
printf("Enter value of a: ");
scanf("%d",&a);
printf("Enter value of b: ");
scanf("%d",&b);
temp = a; /* Value of a is stored in variable temp */
a = b; /* Value of b is stored in variable a */
@scratchyourbrain
scratchyourbrain / C Program to implement sizeof operator
Created December 14, 2014 11:41
C Program to implement sizeof operator
#include <stdio.h>
int main()
{
int a;
float b;
double c;
char d;
printf("Size of int: %d bytes\n",sizeof(a));
printf("Size of float: %d bytes\n",sizeof(b));
printf("Size of double: %d bytes\n",sizeof(c));
@scratchyourbrain
scratchyourbrain / ascii
Created December 12, 2014 11:14
c program to find ascii value of a character
/* to find ASCII value of a character entered by user */
#include <stdio.h>
int main()
{
char c;
printf("Enter a character: ");
scanf("%c",&c);
printf("ASCII value of %c = %d\n",c,c);
return 0;