Answer to Question #27213 in AJAX | JavaScript | HTML | PHP for MARK KEVIN

Question #27213
8. Write a program that will ask the user to input a number of Indians from 1-10. The output must be the number of Indians with the word “little”, it must output by 3 numbers in a line and have the word “Boys” at the end of the output.
Sample input/output dialogue:
Enter a number of Indians: 6
1 little 2 little 3 little Indians
4 little 5 little 6 little Indians Boys
1
Expert's answer
2013-03-28T10:50:36-0400
//main function
int main()
{
int numberofindians=0;//number of Indians
printf("Enter a number of Indians: ");//show user Enter a number of
Indians
scanf("%d",&numberofindians);//read numberofindians
while(numberofindians<1 || numberofindians>11){//if numberofindians<1
or numberofindians>11 try to enter numberofindians again
printf("Enter a number of Indians: ");//show user Enter a number of
Indians
scanf("%d",&numberofindians);//read numberofindians
}
int count=0;//count for 3
for(int i=0;i<numberofindians;i++){//while i less than numberofindians
printf("%d little ",(i+1));//show 1 little 2 little 3 little Indians
count++;//increment count
if(count==3){
printf("Indians
"); //show Indians
}
if(i==numberofindians-1){
printf("Indians Boys"); //show Indians Boys
}
}
scanf("%d",&numberofindians);//delay
return 0;//exit from main function
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS