C-programming-Assignment-[1]
C-programming-Assignment-[1]
Each student must submit to me c codes with comments and your program should
run correctly.
Due date: 28th December 2020 (8:00 AM)
1) Write a C program that allows a user to read two numbers (number1, number2) from
keyboard and use switch case for helping the user to select the operator: If the user selects
“*” as operator then the program will multiply number1 to number2, if the user selects “+”
as the operator the program shall produce the sum of number1 and number2. If the user
selects “-” as operator the program must subtract number1 from number2. If the user
chooses the “/” as operator, the program shall divide number1 by number 2. In any of the
above cases, the answer should be displayed on screen.
2) Find the flowchart and algorithm of a program that finds the minimum of three values a,
b and c.
3) Write a C program that allows a user to read three numbers (number1, number2,
number3) from keyboard and then display the largest number.
4) Write a C program to check whether the given year of input is a leap year or not.
5) Write a C code that computes the surface of a disk given its radius (use scanf). The
number pi will be declared as a constant.
6) Write a C program that prints all numbers between 1 to 100 and also calculates the sum
of even numbers and odd numbers between 1 and 100 both included. (use a for loop)
7) Write a C code that computes the factorial of an integer n. (use a while a loop)
The user shall read n from keyboard.
8) Write a C code that permits the user to specify a number of lines and then prints on the
screen a pyramid consisting of stars. The pyramid must be centered. Hints: all characters
are printed separately and both the number of stars per line and the number of spaces per
line must be calculated. The output will look like: (Use nested loops)
9) Write a C code that permits the user to specify a number of lines and then prints on the
screen the following output. (here for example: number of line is 6) (Use nested loops)
1
22
333
4444
55555
666666
10) Write a C code that permits the user to specify a number of lines and then prints on the
screen the following output. (here for example: number of line is 7)
1
12
123
1234
12345
123456
1234567