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

Answers were Sorted based on User's Feedback



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

Answer / amit sachan

int main()
{
int r,i,q,count=0;
for(i=100;i<300;i++)
{
r=i%10;
q=i/100;
if(r==2&&q==2)
count++;
}
printf("the total no=%d",count)
return(0);
}

Is This Answer Correct ?    40 Yes 1 No

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

Answer / ajithchukku

10

Is This Answer Correct ?    21 Yes 6 No

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

Answer / hana

in between 100 to 300 means 200 to 299...
if u see which starts with 2 and ends with 2 then 202,212,222,232,242,252,262,272,282,292....
hence answer is 10..

Is This Answer Correct ?    11 Yes 2 No

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

Answer / 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

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

Answer / sushma s

PL\SQL Code:

Declare
n number(10) := 0;
begin
for i in 100 .. 300
loop
if (substr(i,1,1) =2) and (substr(i,length(i),1) = 2) then
n := n +1;
dbms_output.put_line('number :'|| i ||' count:' ||n);
end if;
end loop;

end;

O/P: count: 10

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

Is main() is used in the program,,see below example? void main() { int i; for(i=0;i<10;i++) main(); } Then what is the output of the program?

6 Answers  


to find the program of matrix multiplication using arrays

6 Answers   Bhel,


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

5 Answers   TCS, Vimukti Technologies,


define function

4 Answers   Assurgent, Sonata,


Can you think of a logic behind the game minesweeper.

0 Answers  






Ow can I insert or delete a line (or record) in the middle of a file?

0 Answers  


can u give me the good and very optimised code for a car racing game?

0 Answers  


How can I do peek and poke in c?

0 Answers  


write a program for size of a data type without using sizeof() operator?

22 Answers   HCL, IBM,


What is the function of this pointer?

0 Answers   Agilent, ZS Associates,


What is the use of #define preprocessor in c?

0 Answers  


Why is struct padding needed?

0 Answers  


Categories