count the numbers between 100 and 300, that star
with 2 and ends with 2

Answer Posted / sujit

#include<stdio.h>
void main(void)
{
int i,d1,d2,count=0;
for(i=100;i<=300;i++)
{
while(i>0)
{
d1=i%10;
i=i/10;
d2=i%10;
i=i/10;
if(d1==2&&i==2)
count++;
}
}
printf("%d",count);
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c easier than java?

575


What is the use of function in c?

715


How variables are declared in c?

574


Explain b+ tree?

632


What is the difference between text files and binary files?

680






Is it possible to pass an entire structure to functions?

563


What is the meaning of && in c?

552


Explain built-in function?

595


What is sizeof in c?

573


Explain how do you sort filenames in a directory?

612


What are register variables in c?

577


What are two dimensional arrays alternatively called as?

664


What are the uses of a pointer?

685


What do you mean by scope of a variable in c?

546


What does the c preprocessor do?

625