Here, The questions papers of Computer Programming in C of Examination of CTEVT at 1st semester of Diploma in Computer Engineering.
Council for Technical Education and
Vocational Training
Office of
the Controller of Examinations
Sanothimi,
Bhaktapur
Regular/Back Exam, 2076
Program: Diploma in Computer Engineering/IT Full Marks: 80
Year/Part: I/I Pass Marks: 32
Subject: Computer
Programming in C Time: 3hrs
Candidates
are required to give their answers in their own words as far as practicable.
The
figures in the margin indicate full marks.
Attempt Any Eight Questions
1. Define
algorithm and flowchart with example. Differentiate between compiler and
Interpreter. [5+5]
2. What
do you mean by data type in C? Mention about the types of operators used in C
with suitable examples. [3+7]
3. Write
a syntax of switch statement. Write a program in C to display respective day
depending upon the number entered i.e., input 1 for Sunday …………7 for Saturday
using control statement. [2+8]
4. Differentiate
between while and do while loop with reference to their syntax. WAP in C to
read number from keyboard and check if it is palindrome or not. [3+7]
5. What
do you mean by break & continue statement? WAP in C to input a number &
calculate the factorial of that number using recursive function. [3+7]
6. Define
constant and keyword. Explain about nested loop statement with suitable
example. [4+6]
7. Define
an array. WAP in C to calculate the sum of five different numbers with using
array. [2+8]
8. Compare
structure & union with example. WAP in C using structure to display the
name, address, roll no., marks & gender. [3+7]
9. Write
short notes on: (Any Two) [2*5]
a)
Pointer
b)
String handling function
c)
Recursive function
*** Good luck ***
ReplyDeleteWAP in C to read number from keyboard and check if it is palindrome or not.
Here is an example of a C program that reads a number from the keyboard and checks if it is a palindrome:
#include
#include
int main() {
int num, temp, digit, rev = 0;
printf("Enter a number: ");
scanf("%d", &num);
temp = num;
while (num > 0) {
digit = num % 10;
rev = rev * 10 + digit;
num /= 10;
}
if (temp == rev)
printf("%d is a palindrome", temp);
else
printf("%d is not a palindrome", temp);
return 0;
}
This program uses a while loop to reverse the digits of the number entered by the user, and then compares the original number with its reverse. If they are the same, the number is a palindrome, and the program prints "is a palindrome". If they are different, the number is not a palindrome, and the program prints "is not a palindrome".
Write a program in C to display respective day depending upon the number entered i.e., input 1 for Sunday …………7 for Saturday using control statement.
Here is an example of a C program that displays the corresponding day of the week based on a number entered by the user:
#include
int main() {
int day;
printf("Enter a number (1-7): ");
scanf("%d", &day);
switch (day) {
case 1:
printf("Sunday\n");
break;
case 2:
printf("Monday\n");
break;
case 3:
printf("Tuesday\n");
break;
case 4:
printf("Wednesday\n");
break;
case 5:
printf("Thursday\n");
break;
case 6:
printf("Friday\n");
break;
case 7:
printf("Saturday\n");
break;
default:
printf("Invalid input\n");
}
return 0;
}