0% found this document useful (0 votes)
18 views8 pages

POP3rd Internals

Uploaded by

divyashree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views8 pages

POP3rd Internals

Uploaded by

divyashree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

USN

Dr.T. THIMMAIAH INSTITUTE OF TECHNOLOGY


(Estd. 1986) Oorgaum, Kolar Gold Fields, Karnataka – 563120
(Affiliated to VTU, Belgaum, Approved by AICTE - New Delhi)
NAAC Accredited 'A' Grade, NBA Accredited (CSE, ECE, Mining Engg) Program

F.No:DrTTIT/IQAC/2022-23/059AP

Department of Computer Science & Engineering


Third Internal Assessment Test Question Paper

Scheme: 2022 Academic Year:2024-25


Semester: I SEM(A/B/C/D)
Course name: Principles of Programming Course code: BPOPS103
Duration: 60 minutes Max marks: 25
Course Instructor: Prof.Jerusha / Prof.Parvathi /Prof.Sudha S Date: 20/01/25
Answer any three full questions, selecting at least one from each part
Part-A (Ten marks each)
Sl. No Question Marks CO RBT
1a. Define Pointers. Explain how to declare and initialize pointer variable 5 CO4 L2
1b. Write a program to find Sum, Mean, Standard Deviation of array 5 CO4 L3
elements using Pointers
OR
2a. Define String. Explain its declaration and initialization 5 CO4 L2
2b. Write a program to swap contents of two variables using Pointer 5 CO4 L3
technique
Part-B (Ten marks each)
3) Explain the following 10 CO4 L2
(i).strcat()
(ii).strcmp()
OR
4) Explain the Following 10 CO4 L2
(i). Generic Pointer
(ii). NULL Pointer
Part-C (five marks each)
5) Define Structures. Explain its declaration and initialization 5 CO5 L2
OR
6) Explain Enumerated data types 5 CO5 L2

CO Description

CO4 Explore user defined data structures like strings and pointers.

CO5 Design and develop solutions to problems using structures, union, and FILE I/O operations

Course Instructor PAC Member (Name & Signature) HOD


Dr.T. THIMMAIAH INSTITUTE OF TECHNOLOGY
(Estd. 1986) Oorgaum, Kolar Gold Fields, Karnataka – 563120
(Affiliated to VTU, Belgaum, Approved by AICTE - New Delhi)
NAAC Accredited 'A' Grade,NBA Accredited (CSE, ECE, Mining Engg) Program

F.No:DrTTIT/IQAC/2022-23/059BP

Department of Computer Science & Engineering

Third Internal Assessment Test Question Paper

Scheme: 2022 Academic Year:2024-25


Semester: I SEM
Course name:Principles of Programming using C Course code: BPOP103
Duration: 60 minutes Max marks: 25
Course Instructor: Prof.Jerusha/ Prof.Parvathi/ Prof. Sudha S Date: 20/01/25

Part-A

Sl. Brief Solution Marks


No
1a. Pointer 1
It is a variable which contains address of another variable

Declaration

General form:
data_type*pointer_name 2
● * tells thar variable pointer_name is a pointer variable.

● Pointer_name is a identifier

● Pointer_name needs a memory location

● Pointer name_points to a variable of data_type

Ex: int*ptr;
2
Initialization
● Declare a data variable

● Declare pointer variable

● Assign address of data to pointer variable using & operator and assignment
operator

Ex: int x;
int*p
p=&x;
1b.
Program

#include<stdio.h>

#include<conio.h>

#include<math.h>

float a[10], *ptr, mean,


std, sum=0, sumstd=0;
int n,i;ijggjk
printf("Enter the no of elements\n");
scanf("%d",&n);
printf("Enter the array
elements \n");
for(i=0;i<n;i++)
{
scanf("%f",&a[i]);
}
ptr=a;
for(i=0;i<n;i++)
{
sumstd=sumstd
+ pow((*ptr -
mean),2); ptr++;
}
std = sqrt(sumstd/n);
printf("Sum=%.3f\t",sum);
printf("Mean=%.3f\t",mean);

printf("Standard deviation=
%.3f\t", std);

}
2a.. String 1

A string is a null character array.

Declaration
2
It is defined like an array of character

Syntax: data_type string_name[size];

Example: char str[10];

Initialization
2
Syntax: data_type string name[size]=value;

Example: char str[5]=”HELLO”;

2b. Program

#include <stdio.h>

void swap(int *a, int *b)


5
{

int temp = *a;

*a = *b;

*b = temp;

int main()

int x = 5, y = 10;

printf("Before: x = %d, y = %d\n", x, y);

swap(&x, &y);

printf("After: x = %d, y = %d\n", x, y);

return 0;

}
Part-B
3 (i). strcat() 5
It is used to concatenate or join two strings together

Syntax: strcat(destination,source);
Example:
char first[30]=”Computer”;
Strcat(first,last);

(ii). strcmp()
It is used to compare 2 strings. It takes strings as a parameters and returns an
integer value

Syntax: result=strcmp(first,second);
Result=0 🡪first=second
Result>0🡪 first>second 5
Result<0🡪 first<second

Example: int res


res=strcmp(“cat”); //res>0
res=strcmp(“pot”,”pot”); //res=0
res=strcmp(“big”,”small”); //res<0

4) (i)Generic pointer 5
These pointers are used when a pointer has to point to data of different types at different
times
Example:
#include <stdio.h>
int main()
{
int var = 10;
int *ptr = &var;
printf("Value of var: %d\n", var);
printf("Address of var: %p\n", &var);
printf("Value of ptr (address of var): %p\n", ptr);
printf("Value pointed to by ptr: %d\n", *ptr);
return 0;
}

(ii)NULL pointers
A null pointer which is a special pointer value that is known not to point anywhere. It
means it does not point to any valid memory address. 5
To declare a null pointer you may use the predefined constants NULL;
Example:
int*ptr=NULL;
or
if(ptr==NULL)
{
Statement block;
}
Part-C
Structure

Structure is basically a user defined data type that can store related information (even of
different data types) together.

Declaration

struct tagname
{
data_type var-name;
data_type var-name;
……………..
};

Example:
struct student
{
Int r_no;
Char name[20];
5. Char course[20]; 5
Float fees;
};

Initialization

syntax:
struct struct_name;
{
data_type member_name1;
data_type member_name2;
……………………………………….
………………………………………
data_type member_namen;
};
Enumerated data type

Enumerated data type (or enum) is a user-defined data type that consists of a set of
named integer constants.It allows you to define variables that can only take one of a
few predefined values, making your code more readable and maintainable.

syntax
enum enum_name
{
constant1 = value1,
constant2 = value2,
constant3 = value3,
...
};

program
#include <stdio.h>
6 enum day { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; 5
int main()
{
enum day today;
enum variable today = Wednesday;
printf("The value of today is: %d\n", today);
return 0;
}

Course Instructor

You might also like