বিএসসি ইন কম্পিউটার সায়েন্স অ্যান্ড ইঞ্জিনিয়ারিংয়ের (সিএসই) শিক্ষার্থীদের ‘আর্টিফিসিয়াল ইন্টিলিজেন্স’ বিষয়ের সাথে সংশ্লিষ্ট ‘সি’ (C) প্রোগ্রামিংয়ে তৈরি কিছু নমুনা প্রোগ্রাম ডাউনলোড করুন এই লিংক থেকে- www.studentcarebd.com/files/Programs_C++.zip
সি’ (C) প্রোগ্রামিংয়ের গুরুত্বপূর্ণ কিছু প্রশ্ন বা সমস্যা:
1. Write a C program to produce the following output:
2. Write a program containing a for loop to print the message:
3. Your European shoe size can be determined from the length of your foot in centimeters. Take the foot length, subtract 9, multiply by 3, divide by 2, round up, and add 15. Write a C program to read a person’s foot length in inches, convert it to centimeters, and print the corresponding European shoe size. (There are 2.54 centimeters in every inch.)
Your output should look something like this:
EUROPEAN SHOE SIZE
Enter the length of your foot in inches: 9.5
Your European shoe size is 38
Have a nice day!
If the user should input a negative foot length, then your program should print an appropriate message, and halt!
4. My doctor says a man should weigh 106 pounds for the first 5 feet of height, plus 7 pounds for every inch above that; a woman should weigh 100 pounds for the first 5 feet of height, plus 6 pounds for every inch above that. Write a program that determines how much an individual person should weigh. Here’s what your program might look like in action:
Type 1 if you are female and 2 if male: 1
How tall are you?
Number of feet: 5
Number of inches: 10
You should weigh 160 pounds
Type 1 if you are female and 2 if male: 2
How tall are you?
Number of feet: 6
Number of inches: 0
You should weigh 190 pounds
5. Write a program to compute the date of Easter Sunday. Easter Sunday is the first Sunday after the first full moon of Spring. Use the following method, invented by the mathematician Carl Friedrich Gauss in 1800:
a. Let y be the year (such as 1800 or 2001 or whatever)
b. Divide y by 19 and call the remainder a. Ignore the quotient.
c. Divide y by 100 to get a quotient b and a remainder c.
d. Divide b by 4 to get a quotient d and a remainder e.
e. Divide 8 * b +13 by the value 25, to get a quotient g. Ignore the remainder.
f. Divide 19 * a + b – d – g + 15 by the value 30, to get a remainder h. Ignore the quotient.
g. Divide c by 4 to get a quotient j, and a remainder k.
h. Divide a + 11 * h by the value 319, to get a quotient m. Ignore the remainder.
i. Divide 2 * e + 2 * j – k – h + m + 32 by the value 7 to get a remainder r. Ignore the quotient.
j. Divide h – m + r + 90 by the value 25, to get a quotient n. ignore the remainder.
k. Divide h – m + r + n + 19 by the value 32, to get a remainder p. ignore the quotient.
Then Easter falls on day p of month n. For example, if y is the year 2001, we would compute
a = 6
b = 20
c = 1
d = 5, e = 0
g = 6
h = 18
j = 0, k = 1
m = 0
r = 6
n = 4
p = 15
Therefore, in 2001, Easter Sunday fell on 4/15. Write a complete program that allows the user to input a year from the keyboard, and have the program output the month and day values. For one point of “extra credit”, have the month name, rather than the month number, be output (i.e., April 15, rather than 4/15, would be the result).
6. Asif was given a homework in which he had to write the 26 English alphabets. After finishing his homework he found that he had written 25 of them and forgot to write one. Asif knows that you are a good programmer and so asks for your help, as he has got other assignments in hand.
The first line of input will contain an integer N ( N<=10 ) that determines the number of test cases. Each of the next N lines will contain a sorted string of length 25 with one letter missing.
The string will contain only uppercase letters.
For each line of input there will be one line of output. This line will contain the missing uppercase letter.
7. The given numbers are 7, 1, 88, 30, 40, 95, 3, 10, 15, 20. Show these numbers as ascending and descending orders.
8. The Fibonacci numbers are defined recursively as follows:
F1 = 1, F2 = 1, and
Fn = Fn – 1 + Fn – 2 for n > 2
Write a program that will generate and print the nth Fibonacci number.
9. Write a program prime that returns 1 if its argument is a prime number and returns 0 otherwise.
10. A prime number is a number that has only two distinct factors (1 and itself). Therefore the first few prime numbers are 2 3 5 7 11 13 17 …..
A binary prime is a prime number whose number of ones in its binary representation is also a prime number.
– 1910 = 100112.
– 10011 has got 3 ones, which is a prime number.
– it implies 19 is a binary prime.
You have to write a program that will find the Nth binary prime.
Each line of input will contain an integer N. The meaning of N is mentioned above. A value of 0 (zero) for N indicates the end of input, which should not be processed.
For each line of input, output the Nth binary prime. You may assume that every output will be less than 10000. Follow the sample for exact format.
Case 1: 3
Case 2: 5
Case 3: 41
Prepared by: Dr. Shaikh Muhammad Allayear