Download EU EEE Introduction to Computer Programming Laboratory Lab 7

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
EU EEE
Introduction to Computer Programming Laboratory
Lab 7 – Loops
Lab6 – Q7
7) (TICK) Write C code for a program that
receives and unsigned integer and seperates its
digits. If the input value is more than three
digits, greater than 999, a message that says
number has more than three digits is displayed
as output.
123 = 1*100 + 2*10 + 3*1
103 = 1*100 + 3*1
23 = 2*10 + 3*1
1) Write C code for a program that tells if the
student has passed or failed, from the entered
value between 0 and 100. If student has passed,
program outputs letter grade. Use if
statements inside if statements, i.e. nested
ifs.
2) Write C code for a program that tells if the
entered character is a vowel or a consonant. Use
switch statement. Check if the entered
character is a letter with int isalpha(int
c) from ctype.h library. If c is a letter,
isalpha returns a nonzero value. If not, zero is
returned.
3) Write C code for a program that checks if the
input unsigned integer is prime or not. Some
prime numbers are 2, 3, 5, …, 11, 13, 17, …, 101,
103, 107, 109, …
4) Write C code for a program that computes
and displays sub-multiples of the entered
unsigned integer.
5) Write C code for a program that computes
average of the integers entered by user until a
zero is entered.
6) Write C code for guess-the-number game.
First player enter an unsigned integer. The input
is moved out of visible area of console by
multiple new lines. Second player tries to guess
the number and program tips higher or lower.
After a correct guess, total guess count is
displayed.
7) Write C code for a program for computing
power of a number. Inputs are an integer as
base and an unsigned integer as exponent. Use
for statement.
8) Write C code for a program that outputs
Fibonacci sequence until the entered unsigned
integer limit is reached.
In a Fibonacci sequences, an element is sum of two
preceding elements and first two elements are 0
and 1.
Fibonacci Sequence: 0 1 1 2 3 5 8 13 21 34 55 89
144 233 377 610 987 1597 2584 4181 6765 …
Related documents