Thursday 9 January 2014

HOW TO GET ODD AND EVEN NO TO YOUR GIVEN NO

#include<stdio.h>
void main()
{
/*program for get num even or odd
 Date:12\10\2009
made by Dixit Panchal*/
int no,i,index;
clrscr();
printf("enter your value for odd or even untill you want");
scanf("%d",&no);
printf("press 1 for odd number\n");
printf("press 2 for even number");
scanf("%d",&index);
switch(index)
{
case 1:
//odd nos part
//logic of odd nos
printf("\t\t\todd numbers\n\n");
for(i=1;i<no;i=i+2)
{
printf("%d\t",i);
}
break;
case 2:
//even nos part
//logic of even number
printf("\t\t\teven numbers\n\n");
for(i=0;i<no;i=i+2)
{
printf("%d\t",i);
}
break;
}
getch();
}

No comments:

Post a Comment

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...