Thursday, February 24, 2011

Decision Making and Looping

Write a program to print all integers that are no divisible by either 2 or 3 and lie between 1 and 100. Program should also account the number of such integers and print the result.


#include <stdio.h>

void main()
{
int i,count=0;
clrscr();
for(i=0;i<=100;i++)
{
if(i%2!=0||i%3!=0)
{
count++;
printf("%d ",i);
}
}
printf("\nTotal Numbers = %d",count);
getch();
}

No comments:

Post a Comment