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

what is a far pointer

12 Answers   ABB, DRDO, ITI, Maruti Suzuki, Steel Plant, TCS, Toyota, Vivo Mobiles,


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

0 Answers   Wilco,


how can i sort numbers from ascending order and descending order using turbo c..

1 Answers  


Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol

0 Answers  


What is wild pointer in c?

0 Answers  






Explain main function in c?

0 Answers  


Which header file should you include if you are to develop a function which can accept variable number of arguments?

0 Answers   TCS, TISL,


What are the disadvantages of c language?

0 Answers  


main() { int i=5; printf("%d",++i + i); } output is 10 ------------------------ main() { int i=5; printf("%d",i++ + i); }output is 12 why it is so? give appropiate reason....

2 Answers  


difference between string and array?

6 Answers  


Print all numbers which has a certain digit in a certain position eg: number=45687 1 number=4 2 number=5 etc

4 Answers  


Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 1. Print only the alphabets . If in upper case print in lower case vice versa.

1 Answers  


Categories