C PROGRAMMING – ASSIGNMENT 2
Online
execution and submission deadline: 24/10/2026 before 2:00 PM
Written
assignment deadline: 31/10/2026 before 5:00 PM
Submission Instructions
- Write and execute each C program
using the online GDB Compiler.
- Take a clear screenshot of each
program’s execution, including the program output. Write same program and output in your assignment book. Copy and Paste the screenshots of program and result into an MS Word file and keep with you.
- Write each C program and its
result in the same assignment book used for Assignment 1 after executing programs and maintaining word file.
- When submitting the written
assignment book, show the MS Word file containing your screenshots to the
teacher.
Written assignment submission place: Staff
Room
Note: Online GDB is the compiler, not
the place to submit the written assignment book.
Rules and Regulations
- At the beginning of every program,
display your full name and serial number.
- Include the date-and-time code provided in class in every program. When the program runs, it must display the system date and time. Record the program’s output, including the displayed date and time, in your assignment book. The code is time_t now = time(NULL); printf("Date and time: %s", ctime(&now));
- Wherever a question uses n, use
your serial number as the value of n. For example, if your serial number
is 18 (1+8=9), use n9 instead on n.
- Write and test each program
yourself. Do not copy another student’s program or submit someone else’s
work.
- Use meaningful variable names (with number),
proper indentation, and suitable prompts and output messages. Add comments
where they help explain your logic.
- Test each program and record its
output neatly. Check that your name, serial number, and date and time are
displayed correctly.
- Be prepared to run your programs
and explain how they work. The teacher may ask you to make a small change
or answer questions about your code.
2. Largest Even
and Largest Odd: Write a C program to read n integers and display the largest even
number and the largest odd number. If the input contains no even or no odd numbers,
display an appropriate message.
3. Student
Result and Grade: Write a C program to read marks from 0 to 100 and display the
result according to the grade criteria given in Assignment 1. Also display an error
message if the entered marks are outside the valid range.
4. Numbers
Divisible by 3 and 7: Write a C program to display the first n positive numbers
divisible by both 3 and 7.
5. Prime
Number: Write a C program to read an integer and determine whether it is Prime.
6. Frequency of
a Number: Write a C program to read n integers and another integer x, then display
how many times x occurs.
7. Sum of
Digits: Write a C program to read an integer and display the sum of its digits.
Make sure your program also handles zero and negative input.
8. Reverse and
Palindrome: Write a C program to read an integer, reverse its digits, and determine
whether the original number is a palindrome.
GDB online classroom: https://onlinegdb.com/classroom/invite/xKMPtFxJ8
