Showing posts with label c language questions. Show all posts
Showing posts with label c language questions. Show all posts

Thursday, May 2, 2013

c programs using structures


Theory Questions:
1.       What is a structure?
2.       What is an ADT?
3.       What is the syntax for creating a structure?
4.       What is the size of a structure?
5.       What is the use of typedef?
6.       Does structure definition need a semicolon?
7.       Does structure definition exist inside main?
8.       How many structure can have in a program?
9.       Does structure can contain another structure?
10.   Built in structures?
a.       time
b.      FILE
11.   What is Structure initialization?
12.   What is Structure variable Assignment?
Programs (Task):
1.       Create a Employee structure with the following
a.       Members
                                                               i.      Empno
                                                             ii.      Ename
                                                            iii.      Job
                                                           iv.      Salary
b.      Use typedef and provide a alias Emp
c.       Declare a two variables for the structure
d.      Read data into the variables ( structure objects )
e.      Display the data exist in structure object
f.        Display sum of two employee salaries.
2.       Declare two objects for employee stricture and initialize the objects and display.
3.       Initialize two employee objects (a,b),  copy the data into c,d objects and display.
4.       Declare an Address strcture with the following
a.       Members
                                                               i.      DNo
                                                             ii.      Street
                                                            iii.      City
                                                           iv.      Pin
b.      Declare 2 objects
c.       Read data
d.      Display data
5.       Declare structure Array Object for Employee e[12];
a.       Assign data into array object
b.      Display all the employee data
c.       Display male employee
d.      Display female employee
e.      Sort data based on ename
6.       Declare strcture Array object for employee e[10]
a.       Read the data into array object
b.      Display in given order
c.       Display in reverse order
7.       Write a program for the following Menu
a.       Read Employee
b.      Dsiplay Employee
c.       Delete Employee
d.      Search Employee
e.      Edit Employee
f.        Exist
g.       Enter the choice :
8.       Declare a stricture object and initialize the data
a.       Display using function with structure parameter
9.       Create A Time structure
a.       Declare three objects
b.      Assign in time in 1 structure variable
c.       Assign out time in another structure
d.      Display in and out times
e.      Fill the third structure with substation of in and out
f.        Display the session duration.
10.   Create a Date structure
a.       Declare object
b.      Read the data by validating input.
c.       Display the data

programs on arrays in c-language


Character Arrays: (using built in functions from string.lib)

1.                   Read your name into character array and display.
2.                   Read a sentence into character array and display.
3.                   Read a string and display its length using strlen().
4.                   Read a string and display in uppercase using strupr()
5.                   Read a string and display in lowercase using strlwr()
6.                   Read a string and display in reverse using strrev()
7.                   Copy your name into character array name[] and display using strcpy()
8.                   Read 2 names into character array name1[] and name2[] and interchange using strcpy()
9.                   Read your first name into character array name1[] and concat your last name into name2[] and display using strcat()
10.                Read a string and check the given string in palindrome or not using strrev() and strdup()

String manipulations (without using loops)
11.                Read a string and display letters in it.
12.                Read a string and display the count of letters.
13.                Read a string and display the count of small letters.
14.                Read a string and display the count of vowels.
15.                Read a string and display letters in uppercase.
16.                Read a string and display letters in lower case.
17.                Read a string and display the letters in opposite case.
18.                Read a string display the count of words in it.
19.                Read a string and display the string in initcap.
20.                Read a string and display in reverse order.
21.                Read a string and arrange the letters in ascending order.
22.                Read a string and arrange the letters in descending order.
23.                Read a string and eliminate the duplicates in it.
24.                Read a string and search for a letter in it.
25.                Read a string and search for a word in it.
26.                Read a string and copy the string into another character array.
27.                Read a string and add welcome message to it.
28.                Display the following output
K
K I
K I R
K I R A
K I R A N
Display the output
K I R A N
    K I R A
        K I R
           K I
             K

c programs on Functions and theory questions on c language


a)      What is the use of following functions?
a.       gotoxy
b.      kbhit()
c.       delay()
d.      sleep()
b)      Program to display ascii values.
c)       What is enum? How to declare multiple constants using enum.
d)      What is the use const object?



1.       Write a program to develop writechar() function to display character in a specified position. Writechar(‘a’,45,16);
2.       Write a program to develop writestring() function to display string in a specified position. Writestring(“kiran”,10,10);
3.       Write a program to develop hline() to draw a horizontal line. Hline(5, 10, 80 );
4.       Write a program to develop vline() to draw a vertical line. Vline (5, 5, 25 );
5.       Write a program to develop drawbox() to draw a box, drawbox(5,5,70,24);
6.       Write a program to display drawborders() to display borders. Drawborders(5,5,70,24)

List of Exercise c programs on Functions (Returning values)


1.       Write a program to develop functions for the following
a.       return square of the given number in the parameter.
b.      which takes two integer partakers and return sum of the values.
c.       which takes two integer partakers and return biggest of two numbers.
d.      which takes two integer partakers and return smallest of two numbers.
e.      which takes an integer parameter and returns its factorial values.
f.        which takes an integer parameter and return sum of 1 to n.
g.       which takes an integer parameter and return sum of digits
h.      which takes an integer parameter and return the reverse
i.         which takes an integer parameter and return nearby prime.
j.        which takes an integer parameter and return number of zero digits in a given number.
2.       Write a function which takes integer parameter and return true or false for the following
a.       IsZero(9)
b.      IsEven(9);
c.       IsOdd(9);
d.      IsPositive(9)
e.      IsCapital(‘A’)
f.        IsSmall(‘A’)
g.       IsNemeric(‘d)
h.      IsVowel(‘a’)
i.         IsAlphabet(‘%’)
j.        IsAlnum(‘=’)
3.       Write a function which takes integer parameter and return true or false for the following
a.       IsPrime()
b.      IsPalindrome()
c.       IsPerfect()
d.      IsArmstrong()
e.      IsLeapYear()

List of Exercise c programs on functions


1.       What is a Function? What is the Syntax for developing a function?
2.       What is the use of void keyword?
3.       What is a header file and library file?
4.       What is a storage class?
5.       What is the use of #include
6.       What is the use of static storage class?
7.       Explain the following terms
a.       Function prototype
b.      Function Definition
c.       Function Developing
d.      Function Invoking/Calling
                                                               i.      Call by value
                                                             ii.      Call by reference
e.      Function returning value
f.        Recursive functions
8.       What are the important functions exist in following libraries
a.       Conio.lib
b.      Stdio.lib
c.       Math.lib
d.       Ctype.lib
e.      String.lib
f.        Alloc.lib
g.       Dos.lib

c programs on loops(n dimensional)


1. Program to display multiplication tables from 1 and 10
2. Program to display factorial values from 1 and 10
3. Program to display palindrome numbers between 150 250
4. Program to display prime numbers between 1 and 1000
5. Program to display perfect numbers between 1 and 10000
6. Program to display Armstrong number between 1 and 10000
7. Program to display twin primes between 1 and 1000
8. Program to display nearest prime number for the given number

11. Write a program to display the following output.
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
12. Write a program to display the following output.
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5


13.. Write a program to display the following output.

1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5

14. Write a program to display the following output.
5 5 5 5 5
4 4 4 4 4
3 3 3 3 3
2 2 2 2 2
1 1 1 1 1

15. Write a program to display the following output.
a b c d e
f g h i j
k l m n o
p q r s t
u v w x y




16. Write a program to display the following output.
1 1 1 1 1
0 0 0 0 0
1 1 1 1 1
0 0 0 0 0
1 1 1 1 1

17. Write a program to display the following output.
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1


18. Write a program to display the following output.
1 1 1 1 1
1           1
1           1
1           1
1 1 1 1 1




19. Write a program to display the following output.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

20. Write a program to display the following output.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

21. Write a program to display the following output.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5





22. Write a program to display the following output.
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

23. Write a program to display the following output.
1
1 2
1 2 3
1 2
1
24. Write a program to display the following output.
0 0 0 0 1
0 0 0 1 2
0 0 1 2 3
0 1 2 3 4
1 2 3 4 5
25. Write a program to display the following output.
                1
          1 2
       1 2 3
   1 2 3 4
1 2 3 4 5


26. Write a program to display the following output.
 1 2 3 4 5
   1 2 3 4
      1 2 3
         1 2
            1


28. Write a program to display the following output.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1


29. Write a program to display the following output.
1 2 3 4 5 4 3 2 1
1 2 3 4    4 3 2 1
1 2 3         3 2 1
1 2                2 1
1                       1


30. Write a program to display the following output.
        1
      1 2 1
    1 2 3 2 1
  1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
  1 2 3 4 3 2 1
    1 2 3 2 1
      1 2 1
        1

List of Exercise c programs on arrays


1.                   Read 5 elements into an array vector and display.
2.                   Read 5 elements into an array vector and display in reverse order.
3.                   Read 5 elements into an array vector and display sum of elements
4.                   Read 5 elements into an array vector and display biggest element.
5.                   Read 5 elements into an array vector and display smallest element.
6.                   Read 5 elements into an array vector and display average of elements.
7.                   Read 5 elements into an two array’s and merge into 3rd array and display
8.                   Read 5 elements into an array vector and search for a given element (LINEAR SEARCH).
9.                   Read 5 elements into an array vector and search for a given element (BINARY SEARCH).
10.                Read 5 elements into an array vector and add element at last position.
11.                Read 5 elements into an array vector and add element at first position.
12.                Read 5 elements into an array vector and add element at specified n position.
13.                Read 5 elements into an array vector and delete element at specified position.
14.                Read 5 elements into an array vector and implement SELCTION SORT ascending order.
15.                Read 5 elements into an array vector and implement BUBBLE SORT ascending order.

c programs on loops(single dimension)


1.                   Display 1 to 10 numbers
2.                   Display 10 to 1 numbers
3.                   Display 2, 4, 6, 8, 10
4.                   Display 1,3,5,7,9
5.                   Display capital letter alphabets
6.                   Display small letter alphabets.
7.                   Display all letters using their ASCII values
8.                   Display sum of 1 to 10 numbers
9.                   Display sum of 5 to 1 numbers
10.                Write a program to read a number and display its multiplication table
11.                Write a program to read a number and display its factorial value
12.                Write a program to read a number and generate Fibonacci series
13.                Write a program to read a number and display factors of give number
14.                Write a program to read a number and display count of factors
15.                Write a program to read a number and display count of even factors
16.                Write a program to read a number and display sum of factors
17.                Write a program to read a number and display the count digits in a given number.
18.                Write a program to read a number and display count of zero digits in a given number.
19.                Write a program to read a number and display count of odd digits in a given number.
20.                Write a program to read a number and display sum of digits.
21.                Write a program to read a number and reverse the given integer.
22.                Write a program to read a number and check the given number is PRIME or not.
23.                Write a program to read a number and check the given number if ARMSTRONG or not.
24.                Write a program to read a number and check given number is PALINDROME or not.
25.                Write a program to read a number and check the given number is PERFECT number or not