WAP that prints the number from 1 to 100. but for multiplies of
three print "XXX" instead of the number and for the multiplies of
five print "YYY" . for number which are multiplies of both three
and five print "ZZZ"

Answers were Sorted based on User's Feedback



WAP that prints the number from 1 to 100. but for multiplies of three print "XXX" instead..

Answer / abhisekh_banerjee

#include<stdio.h>
void main()
{
int i,n=0,m=0;
for(i=1;i<=100;i++)
{
n=i%3;
m=i%5;
if(n==0 && m!=0)
printf(" XXX ");
else if(m==0 && n!=0)
printf(" YYY ");
else if(n==0 && m==0)
printf(" ZZZ ");
else
printf("%d ",i);
}
}

Is This Answer Correct ?    9 Yes 0 No

WAP that prints the number from 1 to 100. but for multiplies of three print "XXX" instead..

Answer / vadivel t

#include<stdio.h>

main()
{
int i;
for(i = 1 ; i<=100; i++)
{
if((i%5 == 0) && (i%3 == 0))
printf("ZZZ \n");

else if(i%3 == 0)
printf("XXX \n");

else if(i%5 == 0)
printf("YYY \n");

else
printf("%d \n",i);
}
_getch();
}

Is This Answer Correct ?    2 Yes 0 No

WAP that prints the number from 1 to 100. but for multiplies of three print "XXX" instead..

Answer / raju kalyadapu

int main()
{
int i;
while(++i<=100)
{
if(i%3==0)
printf("XXX
");
  else if(i%5==0)
  printf("YYY
");
else if(i%3==0&&i%5==0)
printf("ZZZ
");
printf("%d
",i);
}
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Interview Questions

pgm to find middle element of linklist(in efficent manner)

4 Answers   Huawei,


What is the method to save data in stack data structure type?

0 Answers  


print the palindrome numbers in between 0 to n

1 Answers  


What does a run-time "null pointer assignment" error mean?

2 Answers  


What does static variable mean in c?

0 Answers  






What are near, far and huge pointers?

0 Answers   Hexaware, Thomson Reuters, Virtusa,


What is volatile variable in c?

0 Answers  


Explain two-dimensional array.

0 Answers  


In c language can we compile a program without main() function?

0 Answers  


int n=1; while(1) { switch(n) { case 1:printf("a"); n++; continue; case 2:printf("b"); n++; continue; default : printf("c"); break; } break; }

1 Answers  


What is pointer to pointer in c?

0 Answers  


What is #line?

0 Answers  


Categories