Showing posts with label C programs. Show all posts
Showing posts with label C programs. Show all posts

Monday, July 8, 2013

Encrypt a 4 digit number by adding 7 to each digit and swapping first with third & 2nd with 4rth digit & Decrypt to original again

Encrypt a 4 digit number in such a way that ,later on Decrypt the number to original number :

1)Your program should read a four-digit integer in such a way that it replaces each digit by(sum of that digit + 7)
2)Swap 2nd digit with 4rth
3)Swap 1st digit with 3rd
4)Print the encrypted number

#include <stdio.h>
int main(void)
{
    int num,dig,mod,total = 0,div = 1000,base = 1000,dig1,dig2,dig3,dig4;
    printf("Enter a 4 digit +ve number to be Encrypted : ");
    scanf("%d",&num);
 
    if ( num > 999 && num <= 9999)
    {
        while ( num != 0)
        {
            dig = num / div + 7;
            total = total * 10 + dig ;
            num = num % base;
            div = div / 10;
            base = base / 10;
         
        }
        printf("Total encrypted number is %d",total);
     
            dig1 = (total/1000);
            dig2 = (total % 1000 / 100);
            dig3 = (total % 100 / 10);
            dig4 = (total % 10);
            printf("\nNew Encrypted number is %d%d%d%d",dig3,dig4,dig1,dig2);
    }
    else
        printf("Please Enter a 4 digit +ve number : ");
 
 
    return 0;
}


Part 2 : Decryption to original number :

#include <stdio.h>
int main(void)
{
    int num,dig1,dig2,dig3,dig4,base = 1000,div = 1000,mod,total = 0;
    printf("\nEnter an Encrypted four digit number : ");
    scanf("%d",&num);


    if ( num > 999 && num <= 9999)
    {
        
        dig1 = num / base ;
        dig2 = (num % base)/100 ;
        dig3 = (num % 100)/10 ;
        dig4 = (num % 10);


        num = dig3*1000+dig4*100+dig1*10+dig2;


        while( num != 0)
        {
            mod = num / base - 7;
            total = total + mod * base;
            base = base / 10;
            num = num % div;
            div = div / 10;
        }
        printf("\nDecrypted number is %d",total);
    }
    else
        printf("\nPlease enter a +ve 4 digit number & try again ");
    return 0;
    

}




Wednesday, July 3, 2013

Convert a Binary number to Decimal number without using Pow() or Arrays or Functions



#include <stdio.h>
int main(void)
{
    long int bin;
    int total = 0 ,dec,mod,base =1 ;


    printf("\nEnter a binary number(0's & 1's),I'll tell you its decimal : ");
    scanf("%ld",&bin);


    while ( bin != 0  )
    {
        mod = bin % 10;
        total = total + base * mod;
        base = base * 2 ;
        bin =  bin / 10;
    }


    printf("\nDecimal of %ld is %d",bin,total);
    return 0;
}

Tuesday, July 2, 2013

Enter a 5 digit number to see if its Palindrome number :- For Eg : 12321,45554, 11611

#include <stdio.h>
int main(void)
{
    int i,mod,total,temp;
    printf("\nEnter a +ve 5 digit number : ");
    scanf("%d",&i);
    temp = i;
   
    if ( i > 9999 && i <= 99999 )
    {
    while ( i != 0)  
    {
        mod = i % 10;
        total = total * 10 + mod ;
        i =  i / 10;
    }  
   
    if (total == temp)
        printf("%i is Palindrome ",temp);
    else
        printf("%i is not Palindrome",temp);
    }
    else
        printf("Pl. Enter a +ve 5 digit number :");
       
 return 0;
}

Sunday, June 30, 2013

Print an asterisks( * ) Square out of side size's number input

Write a Program that reads in the side of a square and then prints that square out of asterisks.Your program should work for squares of all sides sizes between 1-20.For example it should look like this :

*****
*      *
*      *
*      *
*****

Code :

#include <stdio.h>
int main(void)
{
    int i = 1,sides,j = 1,m = 1,b = 1,n;
    printf("Enter number of sides of square to be printed :");
    scanf("%d",&sides);
    while ( m <= sides)
    {
        printf("*");
        m++;
    }
 
    while ( b < sides - 1)
        {
            printf("\n*");
            n = 2;
            while ( n < sides )
            {
                printf(" ");
                n++ ;
            }
             if ( n == sides)
                 printf("*");
            b++;
        }
    printf("\n") ;
    while ( i <= sides)
    {
        printf("*");
        i++;
    }  
    return 0;
}

Thursday, August 2, 2012

21 Matchstick Game in C


21 Matchstick Game using C Programming

Write a program for a matchstick game being played between the computer and a user.
Your program should ensure that the computer always wins. Rules for the game are as follows:

-There are 21 matchsticks.
-The computer asks the player to pick 1, 2, 3 or 4 matchsticks.
-After the person picks, the computer does its picking.
-Whoever is forced to pick up the last matchstick loses the game.

Code :
=======

#include <stdio.h>


int main(void)
{
    int i,total = 0,choice,matches = 21,left = 0,k = 0;
    while (  total < 20 )
        
    {
        
        printf("\nEnter your choice of match-sticks between 1-4 :");
        scanf("%d",&i);
        if ( i > 4 || i <= 0 )
            {
             printf("Pl.Enter a valid no between 1,2,3 or 4 :");
             continue;
            }
        total = total + i ;
        left = left - total ;
        
        if( total >= 21)
            break;
            
        choice = 5 - i ;
        printf("\nComputer chooses %d",choice);
        total = total+choice ;
        left = left - choice ;
        printf("\n \nNow total match sticks are %d",total);
        
                
  if (total == 20)
   {
       
      while (k != 1)
      {
          printf("\nEnter your choice of M-sticks you have just one left :");
          scanf("%d",&k);
          if ( k != 1)
              printf("\nPl.enter valid choice : 1 ");
          continue;
      }
          
       
       if(k == 1)
       {
           total = total + k;
           printf("\nComputer wins as you are last to choose match-stick");
           printf("\n \nNow total match sticks are %d",total);
       }
       
  
  
   }   
 
   
}
     return 0;
}
    
   

Friday, September 9, 2011

Find Binary Number Of Any Given Decimal Number


/*Find Binary Number Of Any Given Decimal Number (In Reverse Order) */


#include <stdio.h>
int main(void)
{
    int num,j,k = 0;
    printf("Enter a number whose binary you want to know :");
    scanf("%d",&num);
    j = num ;

    while ( j > 0)
    {
        k = j % 2;
        printf("%d ",k );
        j = j / 2 ;
        continue;
    }

    printf("\n");
    return 0;

}

Euclid's Geometric Position

/*According to Euclid's Geometric Position find Integer Factorization/Prime Factorization of Given Number */


#include <stdio.h>

int main(void)
{
    int i,num,j;
    printf("Enter a number whose Prime factors you want to find :");
    scanf("%d",&num);
    j = num ;    //Assigning value of num to j

    for ( i = 2 ; i <= j-1 ;i++)
    {
         while( num % i == 0)
         {
             printf("\n%d ",i );
             num = num / i ;
             continue;
         }
       
    }
 
   printf("\n");
   return 0;

 }


Monday, September 5, 2011

According to the Gregorian calendar,it was Monday on the date 01/01/1900.If any year is input through the keyboard write a program to find out what is the day on 1st January of this year



Solution code:-
=========


Easy One (Irrespective of difference between year input from year 1901) : 

/*According to the Gregorian calender, it was Monday on the date 01/01/01. If any year is input
 * through the keyboard write a program to find out what is the day on 1st January of this year?*/



#include <stdio.h>
int main(void)
{
    int yr,diff,lpyrdays,normaldays,res;
    printf("\nEnter a year whose day of 1st Jan you want to know : ");
    scanf("%d",&yr);
   
    yr = (yr - 1) ; //removing 1 year as only 1 day we are calculating of current yr
    lpyrdays =  (yr/4)  + (yr / 400) - (yr / 100 ); //Calculating leap days in that particular year
    normaldays = (yr* 365 )+ 1 + lpyrdays ; //Calculating normal days in that year & adding 1st jan's 1 day in
    res = normaldays % 7;
   
   
    if(res==0)
    printf("\nSunday");
    if(res==1)
    printf("Monday");
    if(res==2)
    printf("Tuesday");
    if(res==3)
    printf("Wednesday");
    if(res==4)
    printf("Thursday");
    if(res==5)
    printf("Friday");
    if(res==6)
    printf("Saturday");
   
    return 0;
   
   
   
   
}

Tough One (Solution Code):


#include <stdio.h>

int main(void)          //main function.. starting of c code
{
    int year,differ,lp_year,day_type;
    long int days;
  
   
    printf("Please enter the year: ");
    scanf("%d",&year);
    year=year-1; //we will find days before given year so
    differ=year-1900;


   /*as leap year is not divisible by 100.so,create 2 condition
   one difference less than 100 and greater than 100*/


   if(differ<100)
   {
   lp_year=differ/4; //caln of total no. of leap year
   days=(366*lp_year)+((differ-lp_year)*365+365+1);//see Note1
   day_type=days%7; //caln of day type sun, mon......
   }
  
   if(differ>=100)
   {
   lp_year=(differ/4)-(differ/100)+1+((year-2000)/400);//see Note2           
   days=(366*lp_year)+((differ-lp_year)*365+365+1);//see Note3
   day_type=days%7;
   }


if(day_type==0)
printf("\nSunday");
if(day_type==1)
printf("Monday");
if(day_type==2)
printf("Tuesday");
if(day_type==3)
printf("Wednesday");
if(day_type==4)
printf("Thursday");
if(day_type==5)
printf("Friday");
if(day_type==6)
printf("Saturday");
    
    
  
   
    return 0;  //int main() is function so value must be return.
               //u will read in function chapter
}



/*Note1:
-leap year has 366 day so lp_year*366
-remaining year has 365 day so (differ-lp_year)*365
-add 365 because we reduce 1 year
-add 1 to make jan 1 on which we find day type
     
Note2:
-(leap year come in every 4 year so) (differ/4) for leap year
-(leap year isn't divisible by 100 so we subtract (differ/100)
  from counting as leap year
-(leap year will be if divisible by 400 so ((year-2000)/400)
  to count that year as leap year
- we calculate from 2000 so we add 1

Note3:
-leap year has 366 day so lp_year*366
-remaining year has 365 day so (differ-lp_year)*365
-add 365 because we reduce 1 year
-add 1 to make jan 1 on which we find day type */

Wednesday, August 24, 2011

Validate if given number is Palindrome or not

#include <stdio.h>
int main(void)
{
int i,num,rev= 0,j = 0;
printf("Enter a number for Palindrome check :");
scanf("%d",&i);
num = i;

while ( i != 0 )
{
rev = i % 10;
j = rev + j * 10 ;
i = i / 10 ;
}

if ( j == num)
printf("\n %d is palindrome",num);
else
printf("\n %d is not Palindrome\n",num);
return 0;

}


Sunday, March 21, 2010

Bifurcate entered sentence into uppercase,lowercase,number,special characters & count at the end

/*End user enters sentence/s and you need to bifurcate each entered character whether its number,uppercase character,lower case character ,special character,whitespace character,tab/new line and then reprint the same sentence/s on new line*/

#include <stdio.h>
int main(void)
{
int i;
int big = 0,num = 0,sp = 0,small = 0,space = 0;
while ( (i = getchar()) != EOF )
{
if (( i >= 'a') && ( i <= 'z'))
small++;
else if (( i >= 'A') && ( i <= 'Z'))
big++;
else if (( i >= '0') && (i <= '9'))
num++;
else if ((( i >= 0) && (i <= 31)) || (( i >= 33) && ( i <= 47)) ||((i >= 58) && (i <= 64)) || (( i >= 91) && ( i <= 96)) || (( i >= 123) && ( i <= 127))) //special characters
sp++;
else if (( i == 32) || ( i == 9) || ( i = 10) || ( i = 13)) // for space,tab,newline
space++;
putchar(i);
}
printf("%d lower characters are entered \n",small);
printf("%d Uppercase characters are entered \n",big);
printf("%d White space characters are entered \n",space);
printf("%d Numerical characters are entered \n",num);
printf("%d Special characters are entered \n",sp);
return 0;
}

Thursday, October 8, 2009

Determine Grade of steel

/*A certain grade of steel is graded according to the following conditions:
*1)Hardness must be greater than 50
*2)Carbon content must be less than 0.7
*3)Tensile strength must be greater than 5600
*
*The grades are as follows:
*
*Grade is 10 if all three conditions are met
*Grade is 9 if condition 1 & 2 are met
*Grade is 8 if condition 2 & 3 are met
*Grade is 7 if condition 1 & 3 are met
*Grade is 6 if only one condition is met
*Grade is 5 if none of the conditions are met
*
*Write a program which will require the user to give values of hardness,carbon content and tensile

*strength of the steel under consideration and output the grade of the steel*/

# Solution code :

==========

#include <stdio.h>
int main(void)
{
int hard,ts; // hard = hardness ; ts = tensile strength
float cc; //cc -- Carbon content

printf("\nEnter hardness of steel: ");
scanf("%d",&hard);
printf("\nEnter Carbon content of steel : ");
scanf("%f",&cc);
printf("\nEnter Tensile strenght of steel : ");
scanf("%d",&ts);

if ( (hard > 50) && (cc < 0.7) && (ts > 5600))
printf("Steel is of 10th Grade");
else if ( (hard > 50) && (cc < 0.7))
printf("Steel is of 9th Grade");
else if ( (cc < 0.7) && (ts > 5600 ))
printf("Steel is of 8th Grade");
else if (( hard > 50) && (ts > 5600 ))
printf("Steel is of 7th Grade");
else if ( (hard > 50) || (cc < 0.7) || (ts > 5600))
printf("Steel is of 6th Grade");
else
printf("Steel is of 5th Grade");
return 0;
}

Determine if eligible for premium & Policy

/*An Insurance company follows rules to calculate premium

1)If a person's health is excellent and the person is btw. 25 & 35 years of age and lives in city and is a male then the premium is Rs 4 per thousand and his policy amount cannot exceed Rs 2 lakhs.

2)If a person satisfies all the above conditions except that the sex is female then the premium is Rs 3 per thousand and her policy amount cannot exceed Rs 1 lakh.

3)If a person's health is poor and the person is btw. 25-35 and lives in village and is male ,the premium is Rs 6 per thousand and his policy cannot exceed Rs 10,000

4)In all other cases the person is not insured

Write a program to output whether the person should be insured or not ,his/her premium rate and maximum amount for which he/she can be insured.*/

#Solution
=======

#include <stdio.h>
int main(void)
{
int age,pre,policy_amt;
char sex,live,health;
printf("Enter your age : ");
scanf("%d",&age);
if ( age <= 35 && age >= 25)
{
printf("\nPl.enter your health status ( h/p- h(healthy),p(poor health): ");
scanf(" %c",&health);
printf("\nDo you live in city/Village(c=city)(v=village): ");
scanf(" %c",&live);
printf("\nAre you Male/Female(m=male,f=female : ");
scanf(" %c",&sex);

if ( health == 'h')
{
if ( sex == 'm'&& live == 'c')
printf("\nYou are opt for Rs 4/- Preminum over 1000 Rs & Policy not greater than 2 lakh");
else if ( sex == 'f'&& live == 'c')
printf("\nYou are opt for Rs 3/- Preminum over 1000 Rs & Policy not greater than 1 lakh");
}
else if ( live == 'v' && sex == 'm')
printf("\nYou are opt for Rs 6/- Preminum over 1000 Rs & Policy not greater than 10,000 Rs/-");

if ( sex == 'm' && live == 'c' && health == 'p')
printf("\nSorry no premium or Policy for you");
if ( sex == 'm' && live == 'v' && health == 'h')
printf("\nSorry no premium or Policy for you");
if ( sex == 'f' && live == 'v' && ((health == 'h') || (health == 'p' )))
printf("\nSorry no premium or Policy for you");
if ( sex == 'f' && live == 'c' && health == 'p')
printf("\nSorry no premium or Policy for you");
}

else
printf("\nYou are not eligible for Premium or Policy");

return 0;
}






Determine character input if its Capital,small,decimal or special character

/*Any character is entered through the keyboard ,write a program to determine whether the character entered is a capital letter,a small case letter,a digit or a special symbol

Following is Range of Ascii values for various characters:-

Characters                                           Ascii Values

A-Z                                                        65-90

a-z                                                         97-122

0-9                                                         48-57

Special symbols                                   0-47,58-64,91-96,123-127 */


#1 Solution ( With Value of ASCII characters as integer as input) :-

========================================

#include <stdio.h>
int main(void)
{
int i;
printf("Enter a character to determine its type : ");
scanf("%d",&i);


if ( (i <= 90) && (i >= 65))
printf("\nIts %c whose value is %d ,which belongs to A-Z character type",i,i);
else if ( i <= 122 && i >= 97 )
printf("\nIts %c whose value is %d,which belongs to a-z character type",i,i);
else if ( i <= 57 && i >= 48 )
printf("\nIts %c whose value is %d,which belongs to 0-9 character type",i,i);
else if (( i <= 47 && i >= 0) || ( i <= 64 && i >= 58) || ( i >= 91 && i <= 96) || ( i <= 127 && i >= 123))
printf("\nIts %c whose value is %d,which belongs to specific symbols",i,i);
return 0;
}
 

#2 Solution ( With ASCII Characters as input ) :-

==============================

#include <stdio.h>
int main(void)
{
char i;

printf("Enter a character to determine its type :");
scanf("%c",&i);


if (( i <= 'Z') && (i >= 'A'))
printf("\nIts %c whose value is %d ,which belongs to A-Z character type",i,i);
else if (( i >= 'a') && (i <= 'z' ))
printf("\nIts %c whose value is %d,which belongs to a-z character type",i,i);
else if ( (i >= '0') && (i <= '9'))
printf("\nIts %c whose value is %d,which belongs to 0-9 character type",i,i);
else
printf("\nIts %c whose value is %d,which belongs to *special symbols*",i,i);
return 0;
}


Wednesday, April 15, 2009

Calculate gross salary

/*If his basic salary is less than Rs. 1500, then HRA = 10% of basic
salary and DA = 90% of basic salary. If his salary is either equal to
or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic
salary. If the employee's salary is input through the keyboard write
a program to find his gross salary.*/

Solution Code:-
=========


#include <stdio.h>
int main(void)
{
int bs;
float hra,da,gross;
printf("Enter Basic Salary : ");
scanf("%d",&bs);
if ( bs < 1500 )
{
hra = bs * 10 / 100;
da = bs * 90 /100;

}

else
{
hra = 500 ;
da = bs * 98 /100;
}

gross = hra + da + bs ;
printf("\n Your gross salary is %f",gross);
return 0;
}

Tuesday, April 14, 2009

Print a five digit number by adding one to each of its digits

/*If a five-digit number is input through the keyboard, write a
program to print a new number by adding one to each of its
digits. For example if the number that is input is 12391 then
the output should be displayed as 23402.*/


Solution Code :-
=========

#include <stdio.h>
int main(void)
{
int i,temp = 0;
printf("Enter a +ve 5 digit number :");
scanf("%d",&i);
if (( i <= 99999 ) && ( i > 9999 ))
{
printf(" %d",(i/10000) + 1);
printf(" %d",((( i/100) % 100)/10) + 1);
printf(" %d",(( i/100) % 10 ) + 1);
printf(" %d",((i % 100) / 10) + 1 );
printf(" %d",(i % 10) + 1);
}
else
printf("\n Pl.enter +ve five digit number");
return 0;
}

Monday, April 13, 2009

Calculate price of single item

*If the total selling price of 15 items and the total profit earned
on them is input through the keyboard, write a program to
find the cost price of one item.*/

/*Here the query maker ,I suppose seeks for groce price rate of one item ,as groce profit & groce selling price is sought out
sin => single item groce price ; procin => profit on single item ;con => conjugal price (profit + single item price)
*/

Solution Code :-
==========


#include <stdio.h>
int main(void)
{
int price,profit,sin,prosin,con;
printf("Enter price of 15 items : ");
scanf("%d",&price);
printf("\nEnter profit made on 15 items : ");
scanf("%d",&profit);
sin = price / 15 ;
prosin = (profit / 15) - sin;
con = sin + prosin ;
printf("\nSingle item cost is %d",sin);
printf("\nSingle item profit is %d",prosin);
printf("\nSingle item cost price is %d",con);
return 0;
}

Sunday, April 12, 2009

Find total number of currency notes of each 10,50,100 denominations

/*A cashier has currency notes of denominations 10, 50 and
100. If the amount to be withdrawn is input through the
keyboard in hundreds, find the total number of currency notes
of each denomination the cashier will have to give to the
withdrawer.*/

Solution Code:-
=========

#include <stdio.h>
int main(void)
{
int amt;
printf("Enter the amount to withdraw : ");
scanf("%d",&amt);
printf("\nNotes of 100 required are %d", amt/100);
printf("\nWhile Notes of 50 required are %d", ((amt % 100)/50));
printf("\nAnd notes of 10 required are %d",((amt % 100)% 50)/10);
return 0;
}

Percentage of Literate & Illiterate along with men & women in town

/*In a town, the percentage of men is 52. The percentage of
total literacy is 48. If total percentage of literate men is 35 of
the total population, write a program to find the total number
of illiterate men and women if the population of the town is
80,000*/

Solution Code:-
===========
/*popmen = population of men,popwo = population of women ,literate women = ilwo,ilmen = ill-literate men,limen = literate men,liwo = literate women,li= literate men*/

#include <stdio.h>
int main(void)
{
int popmen,popwo,ilmen,ilwo,li,limen,liwo,total;
popmen = (80000 * 52)/100;
printf("\nTotal population of Men in town is %d out of 80000",popmen);
popwo = (80000 - popmen);
printf("\nTotal population of women in town is %d out of 80000",popwo);
li = ( 80000 * 48)/100;
printf("\nTotal literate population in town is %d",li);
limen = ( popmen * 35 )/100;
printf("\nTotal amount of literate Men are %d",limen);
ilmen = popmen - limen;
printf("\nTotal amount of Ill-literate Men are %d",ilmen);
liwo = li - limen ;
printf("\nTotal amount of Literate women is %d",liwo);
ilwo = popwo - liwo ;
printf("\n Total amount of Ill-literate women is %d",ilwo);

return 0;
}

Saturday, April 11, 2009

Calculate percentage of 5 subjects & display Divison resp.

/*The marks obtained by a student in 5 different subjects are input through keyboard.The student gets a division as per the following rules:

Percentage above or equal to 60 - First division
Per btw 50 and 59 - Second div
per btw 40 and 49-Third div
per less than 40 - Fail */

Solution Code:
=========

#include <stdio.h>
int main(void)
{
int m1,m2,m3,m4,m5,sum,per;
printf("Enter marks for Math : ");
scanf("%d",&m1);
printf("\nEnter marks for Chemistry : ");
scanf("%d",&m2);
printf("\nEnter marks for Biology : ");
scanf("%d",&m3);
printf("\nEnter marks for Physics : ");
scanf("%d",&m4);
printf("\nEnter marks for English : ");
scanf("%d",&m5);
sum = (m1 + m2 + m3 + m4 + m5);
per = (sum * 100 / 500);
printf("\nYou got %d percentage",per);

if ( per >= 60 )
printf("\nFirst Division");

else if (( per <= 59) && ( per >= 50 ))
printf("\nSecond Divison");

else if (( per <= 49 ) && ( per >= 40 ))
printf("\nThird Divison");

else
printf("\nSorry you Failed");
return 0;
}

2nd Solution Code:-
===========

#include
int main(void)
{
int m1,m2,m3,m4,m5,sum,per;
printf("Enter marks for Math : ");
scanf("%d",&m1);
printf("\nEnter marks for Chemistry : ");
scanf("%d",&m2);
printf("\nEnter marks for Biology : ");
scanf("%d",&m3);
printf("\nEnter marks for Physics : ");
scanf("%d",&m4);
printf("\nEnter marks for English : ");
scanf("%d",&m5);
sum = (m1 + m2 + m3 + m4 + m5);
per = (sum * 100 / 500);
printf("\nYou got %d percentage",per);

if ( per >= 60 )
printf("\nFirst Division");
else
{
if ( per >= 50 )
printf("\nSecond Division");

else
{
if ( per >= 40 )
printf("\nThird Division");

else
printf("\nFail");
}
}
return 0;
}


Example of compound statement & nested if

/*Prompts for and accepts input of an integer.Integer is tested to see that it meets the stated criteria.If it doesn't an error message is issued.If all criteria are met,execution terminates silently*/

*Solution Code:-
===========

#include <stdio.h>
int mod(int i);
int main(void)
{
int i;
printf("Enter an Even number less than 20 : ");
scanf("%d",&i);

if ( i < 20)
{
if ( mod(i))
printf("Oops you entered Odd number %d",i);
else if ( i <= 0 )
printf("Oops you entered number less than or equal to 0 %d",i);
}
else
printf("You entered a number greater than 20");



return 0;
}

int mod(int i)
{
return ( i % 2 );
}