Sample Questions

Output Tracing

#include <stdio.h>
int main() {
    int a = 10;
    
    printf("%d %d %d\n", a, a, a);       //10 10 10 //10
    printf("%d %d %d\n", a++, a++, a++); //12 11 10 //12
    printf("%d %d %d\n", ++a, ++a, ++a); //16 16 16 //16
    printf("%d %d %d\n", a++, ++a, a++); //18 19 16 //19
    printf("%d %d %d\n", ++a, a++, ++a); //22 20 22 //22
    
    return 0;
}
#include <stdio.h>
int main() {
    int a = 10;
    int *b = &a;
    
    printf("%d %d %d\n", a, a, a);       //10 10 10 //10
    printf("%d %d %d\n", a++, a++, a++); //12 11 10 //13
    printf("%d %d %d\n", ++a, ++a, ++a); //16 15 14 //16
    printf("%d %d %d\n", a++, ++a, a++); //18 18 16 //19
    printf("%d %d %d\n", ++a, a++, ++a); //22 20 20 //22
    
    return 0;
}

Write C Programs for the following questions:

  • Write down a function that will check whether a year is a leap year or not

  • Write a program to calculate factorial

  • Write a pseudo code to identify whether a given sequence is palindrome or not using stack and queue. You do not need to write code to implement stack and queue.

  • Compute the sum of palindrome numbers between 100 and 999

  • Write a function to reverse a string without using a global variable

    • Write down a method in C++ to reverse a char array. You are not permitted to use temp array and STL lib function.

  • Find the number of integers not divisible by 3, 5, or 7 which are <= 100

  • Write a program using a pointer to insert a number in a sorted list, it was forbidden to use array notation like array[], all should be done by pointer notation.

  • Write a function that takes an integer number and separates each digit using recursion

Write pseudocode

  • Test whether a list is sorted or not

Last updated