Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

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..

#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 ? 8 Yes 0 No

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

#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 ? 1 Yes 0 No

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

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

More C Interview Questions

f(char *p) { p=(char *)malloc(sizeof(6)); strcpy(p,"HELLO"); } main() { char *p="BYE"; f(p) printf("%s",p); } what is the output?

Write a C++ program without using any loop (if, for, while etc) to print numbers from 1 to 100 and 100 to 1;

Difference between exit() and _exit() function?

Explain high-order and low-order bytes.

How can I rethow can I return a sequence of random numbers which dont repeat at all?

define function

Do you know what are bitwise shift operators in c programming?

write a program to display the numbers in the following 4 4 3 3 2 2 1 1 0 1 1 2 2 3 3 4 4

Explain what is wrong with this program statement?

The differences between Windows XP and Windows Visa

How can I get back to the interactive keyboard if stdin is redirected?

What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

Categories