0 喜歡 0 不喜歡
3.6k 瀏覽

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

[練習] 開放式問答 - 最新提問 分類:Chapter 3: Branching, Looping and Functions | 用戶: (5.9k 分)
ID: 30244 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 3.6k 瀏覽
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 個回答

0 喜歡 0 不喜歡
內容已隱藏
** *** ** *


* * *** ** *


* * ** ** {


** *


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


** * *** * ** * *


** *** *


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


*


***


* ***** ** **


*


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


*


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





* ** *


*


*


*



5


* **


**


* *


* *


**


* * **


50/100 最新回答 用戶: (221 分)
修改於 用戶:
0 喜歡 0 不喜歡
內容已隱藏
#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 最新回答 用戶: (244 分)
0 喜歡 0 不喜歡
內容已隱藏
* * * ** *** *


** * * ** ** * **


** * * * *** * ** {


*** a, i;


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


** *** * * ** *


==


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



}





*** ** * * * **


** * *


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


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


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



}


** 0;



}



}
50/100 最新回答 用戶: (183 分)
0 喜歡 0 不喜歡
內容已隱藏
#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 最新回答
修改於 用戶:
0 喜歡 0 不喜歡
內容已隱藏
* * * ** * ***


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



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



int a, i;


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


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


* **** *


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



}



else


* * **** *


**** ***


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


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


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


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



}


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


***** *
100/100 最新回答 用戶: (243 分)
0 喜歡 0 不喜歡
內容已隱藏
#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 最新回答 用戶: (269 分)
0 喜歡 0 不喜歡
內容已隱藏
* * *** ** * * **


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


* * * * * ** **



{


* i;


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


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


* * ** *



{


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



}


* *


** **** * ** * *





* **


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


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


**


*** **



}
50/100 最新回答 用戶: (153 分)
修改於 用戶:
0 喜歡 0 不喜歡
內容已隱藏
2. ** * ** * * ** ** * * * * ** ***** * ** do not * * a * * * * or **** ** * * 15 ** *** ****** ** * * ** Line 18 : } * *** 19 * * *** ***** * *** * * i);
100/100 最新回答 用戶: (283 分)
修改於 用戶:
0 喜歡 0 不喜歡
內容已隱藏
* * * *** ** * *
****** *** * ** * *



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 最新回答 用戶: (269 分)
0 喜歡 0 不喜歡
內容已隱藏
* **** ** 6 * * *** * * * * **** * ** *** , ** ****** *** * * * * * * **** * * * * **** * ** ** * * * * * * a = 0 * * ** a ** * * * a * ** * * ** a ; ** * * to be * * ** * * * * *** * ** a ** ** ** * ** * * * *** * ** * * * ** * a * *** * * * *** * ** * * * ** * ** ** a * ** * * *
** * * * * * * * ** * * * * ** * a ** * ***
100/100 最新回答 用戶: (273 分)
0 0
Excellent job
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.243.109
©2016-2026

相關問題

1 喜歡 0 不喜歡
23 回答
[練習] Coding (C) - 最新提問 10月 22, 2017 分類:Chapter 3: Branching, Looping and Functions | 用戶: semicolon (5.2k 分)
ID: 28184 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 9.7k 瀏覽
0 喜歡 0 不喜歡
24 回答
[練習] Coding (C) - 最新提問 11月 2, 2017 分類:Chapter 3: Branching, Looping and Functions | 用戶: nat236919 (5.9k 分)
ID: 30241 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 7.9k 瀏覽
1 喜歡 0 不喜歡
23 回答
[練習] Coding (C) - 最新提問 10月 20, 2017 分類:Chapter 3: Branching, Looping and Functions | 用戶: nat236919 (5.9k 分)
ID: 28130 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 8.1k 瀏覽
1 喜歡 0 不喜歡
0 回答
[Resource] 最新提問 10月 16, 2017 分類:Chapter 3: Branching, Looping and Functions | 用戶: nat236919 (5.9k 分)
ID: 27158 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 17 瀏覽
0 喜歡 0 不喜歡
17 回答
[練習] 克漏字填空 - 最新提問 11月 26, 2017 分類:Chapter 3: Branching, Looping and Functions | 用戶: nat236919 (5.9k 分)
ID: 34344 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 3.3k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶