Pseudo code for In-class QuestionExample 3: Write pseudo code that performs the following: Ask a use
来源:互联网 发布:零趣tk域名 编辑:程序博客网 时间:2024/05/16 00:31
Example1: Write pseudo code that reads two numbers and multiplies them together and print out their product.
Output:"Please Enter 2 Numbers:"
Input int a,b
Output a*b
Example2:Write pseudo code that tells a user that the number they entered is not a 5 or a 6.
Output:"Please Enter a Number:"
Input int a
If a!=5||a!=6
Output:"No"
Else
Output:"Yes"
End if
Example 3: Write pseudo code that performs the following: Ask a user to enter a number. If the number is between 0 and 10, write the word blue. If the number is between 10 and 20, write the word red. If the number is between 20 and 30, write the word green. If it is any other number, write that it is not a correct color option.
Output:"Please enter a number:"
Input an integer n
If 0-9
Output: "Blue"
Else if 10-19
Output: "Red"
Else 20-30
Output: "Green"
Else
Output:"Wrong Color Option"
End if
Example 4: Write pseudo code to print all multiples of 5 between 1 and 100 (including both 1 and 100).
Output:"This program will print all multiples of 5 between 1 and 100."
While int i>=1&&i<=100
If i%5==0
Output i
End if
i++
End loop
Example 5: Write pseudo code that will count all the even numbers up to a user defined stopping point.
Output:"Please Enter a Number:"
Input int a
While i>=0&&i<=a
If i%2==0
Output i
End if
i++
End loop
Example 6: Write pseudo code that will perform the following.
a) Read in 5 separate numbers.
b) Calculate the average of the five numbers.
c) Find the smallest (minimum) and largest (maximum) of the five entered numbers.
d) Write out the results found from steps b and c with a message describing what they are
Output:"Please Enter 5 Numbers:"
Input int a[0], a[1], a[2], a[3], a[4]
int b
Output "The Average is (a[0]+ a[1]+ a[2]+ a[3]+a[4])/5"
int max=0
For(int i=0;i<=4;i++)
for (int j=0;j<=4)
If a[i]>=a[j]
b=a[j]
a[j]=a[i]
a[i]=b
End if
End loop
End loop
Output "Output the smallest one is a[0], and the largest one is a[4]"
Example 7: Write a pseudocode solution which will take in an integer value and determine whether that value is odd or even.
Output:"Please Enter a Number:"
Input int a
If a%2==0
Output:"Even"
Else
Output:"Odd"
End if
- Pseudo code for In-class QuestionExample 3: Write pseudo code that performs the following: Ask a use
- LightOj 1054 Efficient Pseudo Code
- pseudo-class, pseudo-element, pseudo-CSS
- [cn]伪代码 --- pseudo code[en]
- Pre-IPL RAM Stage pseudo C code
- Light oj 1054 - Efficient Pseudo Code
- Light OJ 1054 - Efficient Pseudo Code
- Abnormal Ball, I found you die: Easy Algorithms in pseudo-code
- a example for calling java code in javascript use dwr
- 1414 - OUT or INOUT argument 3 for routine nenghao.xxx is not a variable or NEW pseudo-variable in B
- lightoj1054 Efficient Pseudo Code(欧拉函数+Divisor function)
- T-CODE that exists in the SAP
- A simply client code for that server.
- Question 26: Which of the following options describe the expected overhead for a class that has 5 virtual functions?
- Add a pseudo instruction
- The file contains a character that cannot be represented in the current code page (936)
- warning C4819: The file contains a character that cannot be represented in the current code page
- VSE: The file contains a character that cannot be represented in the current code page (936).
- C编程之预处理标识符——__LINE__,__FILE__,__DATE__,__TIME__,__STDC__,#,##
- 学生信息管理系统 SSH 框架使用及范型使用
- robotium整理(二)
- open_input_file()函数介绍
- kill adb.exe
- Pseudo code for In-class QuestionExample 3: Write pseudo code that performs the following: Ask a use
- 【杂谈】蓝屏修复杂谈
- Shell脚本快速入门
- ld: warning: directory not found for option 去掉警告的方法
- Redis(一 安装使用)
- 在windows中创建ftp服务器
- 广播、组播、点播的区别
- SPOJ 7001 Visible Lattice Points(莫比乌斯反演)
- 超清、高清、标清