0 like 0 dislike

Please look through the code given below; there might be something wrong. You are asked to state what parts are missing or wrong, explain how to fix the code. Then tell us what the output will be

** This is an essay question **

Code

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
	int a, i;
	printf("Enter a number: ");
	scanf
	
	if(a=0){
		printf("Please do not enter a negative number or zero")
	}
	
	else
	
	for(i=1;i<=a;i+){
		if(i%2!=0){
		printf("\n %d--Odd", i);
		
		printf("\n %c--Even", i);
	}
	
	return 0;
}

 

****    % = reminder of division

[Exercise] Essay (Open question) - asked in Chapter 3: Branching, Looping and Functions by (5.9k points)
Available when: Unlimited - Due to: Unlimited
| 172 views
0 0
What do you mean by reminder of division? do we have to divide by 2?
0 0
Hi.

It's just an explanation of an operation called 'Moderator'. By using it, it keeps a remainder number. Such as
2%4 = 2        remainder = 0
2%5 =  2        remainder = 1

14 Answers

0 like 0 dislike
Hidden content!
* ** * * **


**** ** **** * *


* * ** * * ** {


* *


* * * * * ** a * **


* * *** ** * ***** *


* * * ** **


* * ** ** * * a * * * * **


*


**


* ** * * **


* * *


* *** *** * ** * *


*


* * * ****** *


*


* ** **


**





*



5


* ** *


**


* *


*


*


**


*
50/100 answered by (221 points)
edited by
0 like 0 dislike
Hidden content!
#include ** * *** * * * **** * * * * main(int argc, char *argv[]) {    int a, * ** * * * * *** * * a number: * **** ** * * * ** * ** * * * * * **** * * *** * ** ** *** * * ** ** * *** ** * ** *** * *** * ** * **** * * * ** do not enter a negative number or * ** * * * ** *** * ** * **** * * ** * ****** * *** * ***** ** * * * * *** * ** ** * *** ** *** * *** * * * ***** ******* * * * * * ** * ** ** * ** * **** *** %d--Odd", ****** * *** ** * ** ***** ***  else * * * ** ** **** * *** * * * * * * * * %d--Even", ** * ** * * **** * *** *** * * ** **** *  return 0;}
50/100 answered by (244 points)
0 like 0 dislike
Hidden content!
*** ** ********* * *


* **** * *****


* ** **** {


** a, i;


** ** ** ** * a ** **


* * * *** * * * *


* == **


****** ** do * * a * * or **** **



}


**


** * **** * ** ***


*


* * * *** *** * *


*** ** ** ** *** * *


****** * * * * * ** i);



}


** 0;



}



}
50/100 answered by (183 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main(int argc, char *argv[]){



int a, i;



  printf("Enter a number: ");



  scanf("%d",&a);



    if(a<=0){



  printf("Please do not enter a negative number or zero");



}



 else{



 for(i=1;i<=a;i++){


*** *** **** ** * ** * ** * **** ** * * **** * ** * **** * ** * **** * ** ** ** * * ** * * ** * ** ** **


******* * * ** ** **** * * ** ** *** ** **** * ****** *** * * * ** ***** * * * ** * * * * * ** * * * **** ** * *** ** * **** ** * **** * *** ** * ** ** ** * * ** ** *** *** *


** ** * **** ***** * *** *** ******* * ** * ****** ****** *** ** * * ** **** *** * ** **** *** * *** * *** * * ** * ** * * **** ** * ** ***


** * * * ** * * ** * *** * ** ***** ** *** ***** ** * ** ** * ** * **** * ** ****** *** ** * ****** * * * ***** * **** ** * * **** * ** ** * *** *** ** **


* * *** ** ** * * * *** * ** ** **** * *** * ** * ********* * * * ****** * * ** ** * *** *** ** * * * **** * * ** ***** ** * * ** ** **** * * * **** ** * * * * * ** * ** * ** * *** *** * ** ** * *** ** ** ** * ****** ** * *


** ** **** * **** **** * ******* * * *** * **** * *** * ** ** * **** *** * * * **** * * * ** ** **** * *** ** ** *** *** ** * * ** * ** ** * * **** * ******** ** ** * * ****


* * *** * ** ******* ***** *** ***** ** * * ** ** ** * * * *** ** * * * * * * * ** * ** ** **** * * *** ** *** * * * * * *** *** ** * * * * * * * * ** * ********* ********



Example1 **** ***** * *** *** * *** *** * * * * *** ***** * * **** * * ** * * *** * ** * * ** ** * * * * * ** **** * ** * * *** ** ** * * * ** ** * * * * ** * * * * **** * **** ** * ** *** * * * * * ******* *** *** * *** * ** * **



input: 5 * *** ** ** *** *** ** * ** * * * ** **** * ***** ** ** * ** * ** * * * * *** ** *** *** *** ** * **** ** * * * * ** * * ** **** * ** *** * ** * * ** * *** ** *** ** * * * * *** * * * ** *** * *** * ** **** ** *** *** ****** * ***** * ** ** * ** ***** or -100



output: 5--odd **** * * ****** ** * **** *** * * *** * * * * ** * ** * *** 6--even *** * * **** *** * ** ** * * ***** *** * * **** *** ** * * *** * * * * * * * * ** * Please do not enter a negative number or zero



Conclusion: This code is to check the number is odd or even. If the input: 0 or negative number, it will say:Please do not enter a negative number or zero.
0/100 answered
edited by
0 like 0 dislike
Hidden content!
* *** ** * * * *** *


* ***** **** **



int * *** argc, char * ** {



int a, i;


**** * * ** * ** * a number: * * *


** ** *** * * * **** ** *


*** *****


*** * do not enter a * * number or * * ** *



}



else


** ** ****


* *


** * ** * ****** ** i);


* ** ** * *** **** * * ****** * ** ***


** * ** * * i);


* * ** * * ** * ** * ** * *****



}


** ***** * * * * * *** * ** * ** *** *** ** 0;


* **
100/100 answered by (243 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



#include <stdlib.h>



int main(int argc, char *argv[])



{



  int a, i;



  printf("Enter a number: ");



  scanf("%d",&a);



  



  if(a==0){



  printf("Please do not enter a negative number or zero");



}



 else{



 for(i=1;i<=a;i++){


* * * ** * **** * ** *** ** * * * ** * * *** * ** ** * **** * *** **** * *** * ** * * ***


*** *** * *** ** *** **** * ** ** ******** * **** *** * ***** ** * ** ** * *** * ** **** * *** ** **** * ******* * * ** ** ** * ******* * ** *** ** *** ** *** * **** ** * * ** ***** ** * * **


*** **** ** ** *** *** * **** **** * **** * *** ** * * ** * * ** * * ** * ** **** *** * * *** ** * * * * ** *** * *** * * * * ** ** * * * ** *** **


** * ** *** ** *** * ** *** * * * *** * * ** *** *** * ** ******* * * *** * ** * ** * * ***** ** ** ** * * * * **** * * * ** ** ***** ** ** **** * * *


** * * ** ** * * ***** ** *** *** ** * * ** * * * *** ** * * *** *** *** ** ** *** * ** **** ** * * *** * * ** ** * * * ** *** * ** ** * * ** ** * ** **** * ** **** ******** * **** * ** * * * ** *** ** ** ***** *


* **** **** ** * * ** * ** ** *** * ** ** ** ***** *** ****** ** **** * * ** * * ***** * * ** ** ******** ** * * ** *** ** * ****** * * ** **** * ** *** ** **


* * * * * * * ***** *** * * ** ** * *** * ****** * * *** * * * ***** * * ** * *** * ** ** ** * ** ** * * ** *** * * ****** * ** * ** ** *** ***** **** **** *** *** * * *** * * **


* ***** ** **** * * ** * * ** * * * * * * * * ** * * *** * * ** * * * * ** * * * * ****


* ** ** * * * ****** * * *** *** ***** **** ** * *** *



  system("PAUSE");



  return 0;



}
50/100 answered by (269 points)
0 like 0 dislike
Hidden content!
*** * ***** **


* ** * * * * ***


** *** *** *



{


*** * i;


* * *** * a *** **** *


* * * * * ***


*** ***



{


** ** * * ** * * ** ** * a * ** * * * or *** * * *



}


***


* ** *** * *





*** **


** ** * * * * *


* * ** * *** * ** *









}
50/100 answered by (153 points)
edited by
0 like 0 dislike
Hidden content!
2. * * ** * * * * * ** * * * ** **** * * *** * do not ** a *** * * * or ** **** * 15 *** * **** * * * * Line 18 : } ** * 19 * * **** *** ***** *** i);
100/100 answered by (283 points)
edited by
0 like 0 dislike
Hidden content!
** ** * ** * ***
* * ** * * ** * *** **



int * ** argc, char ** {
* *** * ** int a, i;
**** ** ** ** *** ** * * a ** ****
* ** * * ** ****** *** ***
* *** **

** *** **** * **
** * * ** * * *** *** * ** * ** ** do not enter a ****** number or * ******
* * **** }
** * * * *

***** * * *** else
* * * ** *

* * * * for(i **** 1 ; i ** *** a ; i++){
*** * * * ** ** * if(i%2 != 0){
* * * ** * *** ** * * * ** *** * i);
* * * }
** **** * ** * *** ** * else{
* *** ** * * ** * * * * **** * * i);
* * ** **** * * ** * * * * }
* * * ** * }
**** *** *

* * ** ***** * 0;

}
50/100 answered by (269 points)
0 like 0 dislike
Hidden content!
* ** * 6 ** ** ** * * * * * * * ** * , * * *** *** *** ** * * ** ** * *** ** ** * ** * * *** * a = 0 *** ** a * * ** ** a ** * * * * * a ; * * to be **** *** * *** * ** * a * * * * ** * * ** * **** * ** ** *** a * * * * * * ** * * ** ** * ** * * a * * * * ***
** * ** ** * ** * *** *** * * * ** * * ** * a ** *
100/100 answered by (273 points)
0 0
Excellent job
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.63.246
©2016-2020

Related questions

0 like 0 dislike
24 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
Available when: Unlimited - Due to: Unlimited
| 296 views
1 like 0 dislike
23 answers
[Exercise] Coding (C) - asked Oct 20, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
Available when: Unlimited - Due to: Unlimited
| 623 views
1 like 0 dislike
23 answers
[Exercise] Coding (C) - asked Oct 22, 2017 in Chapter 3: Branching, Looping and Functions by semicolon (5.2k points)
Available when: Unlimited - Due to: Unlimited
| 294 views
1 like 0 dislike
0 answers
[Resource] asked Oct 16, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
Available when: Unlimited - Due to: Unlimited
| 17 views
0 like 0 dislike
17 answers
[Exercise] Fill in the blank - asked Nov 26, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
Available when: Unlimited - Due to: Unlimited
| 181 views
10,769 questions
120,689 answers
112,784 comments
3,802 users