Showing posts with label question papers. Show all posts
Showing posts with label question papers. Show all posts

Wednesday 7 September 2016

Solar system using structure

  Develop a structure to represent a planets in the solar system. Each planet has the field for the planets name, its distance from the sun in miles and the number of moon it has. Write a program to read the data for each planet and store. Also print the name of the planet that has the highest number of moons.

#include<stdio.h>
struct SolarSystem
{
            char name[30];
            int distance;
            int moons;
}planet[9];

void main()
{
                 int i, max_moons,  pos;
                printf("\nEnter planets records: \n");
                for(i=0;i<9;i++)
                {
                                printf("\nEnter the name of the planet: ");
                                scanf("%s",  planet[i].name);
                                printf("\nEnter the distance of the planet from sun: ");
                                scanf("%d", &planet[i].distance);
                                printf("\nEnter the number of moons for planet: ");
                                scanf("%d", &planet[i].moons);
                }
                printf("\nPlanets records: \n");
                printf("\n---------------------------------------");
                printf("\nName\tDistance\tMoon");
                printf("\n---------------------------------------");
                for(i=0;i<9;i++)
                {
                                printf("\n%s\t%d\t%d", planet[i].name,planet[i].distance, planet[i].moons);
                }
                max_moons = planet[0].moons;
                pos=0;
                for(i=0;i<9;i++)
                {
                                if(planet[i].moons> max_moons)
                                {
                                                max_moons = planet[i].moons;
                                                pos=i;
                                }
                }
                printf("\nThe planet having highest number of moons is %s",  planet[pos].name);
}

Output:
(Note:  Distance in million miles)
Enter planets records:
Enter the name of the planet: Mercury
Enter the distance of the planet from sun: 36
Enter the number of moons for planet: 0

Enter the name of the planet: Venus
Enter the distance of the planet from sun: 67
Enter the number of moons for planet: 0

Enter the name of the planet: Earth
Enter the distance of the planet from sun: 93
Enter the number of moons for planet: 1

Enter the name of the planet: Mars
Enter the distance of the planet from sun: 142
Enter the number of moons for planet: 2

Enter the name of the planet: Jupiter
Enter the distance of the planet from sun: 483
Enter the number of moons for planet: 62
Enter the name of the planet: Saturn
Enter the distance of the planet from sun: 888
Enter the number of moons for planet: 53

Enter the name of the planet: Uranus
Enter the distance of the planet from sun: 1784
Enter the number of moons for planet: 21

Enter the name of the planet: Neptune
Enter the distance of the planet from sun: 2794
Enter the number of moons for planet: 13

Enter the name of the planet: Pluto
Enter the distance of the planet from sun: 2647
Enter the number of moons for planet: 3

Planets records:
----------------------------------------------------------------------
Name                    Distance               Moon
-----------------------------------------------------------------------
Mercury                 36                          0
Venus                     67                          0
Earth                      93                          1
Mars                      142                         2
Jupiter                   483                         62
Saturn                   888                         53
Uranus                 1784                        21
Neptune               2794                        13
Pluto                    2647                         3
The planet having highest number of moons is Jupiter


Friday 2 September 2016

DMA questions set

Dynamic Memory Allocation Function
Data Strutures 15CS33

1.      Explain what is static and dynamic memory allocation? Explain with examples dynamic memory allocation functions.
(December 2007)
(June 2009)
(December 2010)
(June 2012)
(December 2012)
(December 2014)
(December 2015)
(9 marks)


Pointers Questions Set

Pointers
Data Structures 15CS33


1.      Given the following declarations:
            int x ;
            double d;
            int *p;
            double *q;
            Which of the following expressions are not allowed?
i)                    p = &x;
ii)                  p = &d;
iii)                q = &x;
iv)                q = &d
v)                  p = x;
            (December 2007)
            (5 marks)

2.      Show what would be printed from the following block:
            #include<stdio.h>
            void fun (int (*p)[3])
            {
                        printf ("\n%d %d %d", (*p)[0], (*p)[1], *p[2]);
                        return;
            }
            void main()
            {
                        /* local definitions */
                        int x [2][3] =  { { 4,5, 2}, { 7,6, 9}  };
                        /* statements */
                        fun (x);
                        fun (x+1);
                        return 0;
            }
            (December 2007)
            (6 marks)

            Output:
            4          5          2686792
7              6          2130567168

3.      What is pointer variable? Can we have multiple pointer to variable?
(June 2009)
(December 2009)
(June 2010)
(6 marks)
   
4.      Show the output of the following block:
            main()
            {
                        int num[5] = {3,4,6,2,1};
                        int *p = num;
                        int *q = num+2;
                        int *r = &num[1];
                        printf("\n%d %d", num[2], *(num+2));
                        printf("\n%d %d", *p, *(p+1));
                        printf("\n%d %d", *q, *(q+1));
                        printf("\n%d %d", *r, *(r+1));
            }
            (June 2009)
            (December 2010)
            (6 marks)

            Output:
            6          6
            3          4
            6          2
            4          6

5.      What is pointer to pointer?Write a C program to find the smallest element in an array (using pointer and function)
(December 2009)
(7 marks)

6.      Write the output of the following
#include<stdio.h>
main()
{
                  int a = 5;
                  int b = 7;
                  int *p = &a;
                  int *q = &b;
                  printf("\n%d", ++a);
                  printf("\n%d", ++(*p));
                  printf("\n%d", --(*q));
                  printf("\n%d", --b);
}
(December 2009)
(4 marks)

Output:
6
7
6
5


7.      Write a C program to read 10 integers and store them in an array using pointers. Print their sum and average.
(June 2010)
(5 marks)

8.      What is pointer? What are the uses of pointers?  How do you declare and initialize the pointers? How do you access the value pointed by the pointers?
(June 2010)
(December 2010)
(June 2012)
(December 2012)
(June 2013)
(June 2014)
(December 2014)
(5 marks)

9.      Write a C function to swap two numbers using a pointers.

      (June 2012)(5 marks)

Friday 26 August 2016

Topic wise VTU Data Structures questions 15CS33

Complied set of Topic wise VTU Data Structures questions 15CS33 


Module 1:


Pointers                                            Download

Strutures and Unions                      Download

Dynamic Memory allocation           Download

Arrays                                               Download

Strings                                               Download

Module 2:


Stack                                                  Download

Recursion                                          Download

Queue                                                Download 


VTU Data Structures Question Papers

VTU Data Structures Question Papers 

Year-wise Question Papers

Credits: www.stupidsid.com


December 2007      Download

June 2009               Download

December 2009      Download

June 2010               Download

December 2010      Download

June 2011               Download

December 2011      Download

June 2012               Download

December 2012      Download

June 2013               Download

December 2013      Download

June 2014               Download

December 2014      Download

June 2015               Download

December 2015       Download