0 like 0 dislike
4.1k views

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)
ID: 30244 - Available when: Unlimited - Due to: Unlimited
| 4.1k 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
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.159.115.10
©2016-2026

Related questions

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)
ID: 28184 - Available when: Unlimited - Due to: Unlimited
| 10.5k views
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)
ID: 30241 - Available when: Unlimited - Due to: Unlimited
| 8.7k 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)
ID: 28130 - Available when: Unlimited - Due to: Unlimited
| 9.1k views
1 like 0 dislike
0 answers
[Resource] asked Oct 16, 2017 in Chapter 3: Branching, Looping and Functions by nat236919 (5.9k points)
ID: 27158 - 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)
ID: 34344 - Available when: Unlimited - Due to: Unlimited
| 3.8k views
12,783 questions
183,442 answers
172,219 comments
4,824 users