Anda di halaman 1dari 5

The Islamia University of Bahawalpur

Department: Mathematics Ist/A-12

MSc. Maximum Marks: 50

Paper: 219 (C++ & Its Applicatio to Numerical Analysis) Time Allowed: Hrs.

Note Attempt Five Question including compulsory Q.No.1. selecting at least One question from each Section

Q.No.1

i) Write down the syntax of the “move to “ function

Syntax : moveto(int x, int y);

moveto function changes the current position to (x, y). Means if you want to move a point from the current
position to a new position then you
can use this function.

ii) Define the term “execution”.

execution are terms that describe the process of running a computer software program or command. The
program in running is also known as execution.

iii) Define the term “Preprocessor directive”.

Preprocessor directives are lines included in the code of programs preceded by a hash sign (#). These lines are
not program statements but directives for the preprocessor. The preprocessor examines the code before
actual compilation of code begins and resolves all these directives before any code is actually generated by
regular statements. P.No.30

iv) If x=20, y=15, z=5 then write down the output of the following expression ( x<y) && (z==5)

Answer: False

v) Define compound assignment expression and give example.

Section-I

Q.No.2 Define the following computer terminologies:

Data , file , varible, const qualifier and define directive.

Data: Raw facts and figure is known as data e.g 25, ali etc
File: A file is a collection of data stored in one unit, identified by a filename. It can be a document, picture,
audio or video stream, data library, application, or other collection of data. The following is a brief description
of each file type. A file may be a source program, pic,pdf etc.

Varible: P.No.54

const qualifier P.No.57

define directive P.No.57

Q.No.3 a) Define arithmetic expression and wite down the order of precedence of operatoions.

An arithmetic expression is a syntactically correct combination of numbers, operators, parenthesis,


and variables.

25 + 15 32.128 - 19.6 + 3.2


Operator Precedence page No.65

b) Define constants and discuss three different types of constants in C++. P.No. 56

Q.No.4 a) Discuss the term “cout-output stream” with examples also discuss its general syntax. P.No.92

b) Write a program in C++ to read the temperature in Fahrenheit, convert the temperature to Celsius degrees

by using the formula

#include <iostream.h>
#include<conio.h>

void main() {
float c;
float f;

cout << "Enter temperature in Fahrenheit: ";


cin >> c;
c = (9.0/5.0) * (f - 32);
cout << " Celsius degrees = " << c << endl;
getch();
}

Q.No.5 a) Discuss the “switch” structure and its execution. P.No.92

b) Write a program to input two integers values and find out whether these numbers are equal or different?

#include <iostream.h>
#include<conio.h>
void main() {
int a,b;
cout << "Enter first Number: ";
cin >> a;
cout << "Enter 2nd Number: ";
cin >> b;
if(a==b)
cout << " Numbers are equal”;
else
cout << " Numbers are Not equal”;
getch();
}

Section-III

Q.No.6 a) Discuss the logical operators AND , OR and NOT. P.No.92

b) Write a program to print a natural numbers 1 to 10 in descending order.

#include <iostream.h>
#include<conio.h>

void main() {
int n;
cout<<”1 to 10 Natural Number series in descending order”<<endl;
for(n=10; n>=1; n--)
cout << n<”\t”;
getch();
}

Q.No.7 a) Write a program in C/C++ to find out and print the maximum value in the array: { 15, 11, 2, 6, 13,
16, 12, 4}

#include <iostream.h>
#include<conio.h>

void main() {
int n[]={ 15, 11, 2, 6, 13, 16, 12, 4};
int max=0;
for(int a=0; a<=7; a++)
{
if( max<n[a])
max=n[a];
}
cout<<”The maximum value in tha array: “<<max;

getch();

b) Write a program to input data into two different arrays and then to add the two arrays and store the result
in a third array.
#include <iostream.h>
#include<conio.h>

void main() {
int n,a;
cout<<”enter the length of array”;
cin<<n;
int array1[n],array2[n],array3[n];
Cout<<”Enter elements of ist array”

for(a=0; a<n; a++)


{
Cin>>array1[a];
}
Cout<<”Enter elements of 2nd array”

for( a=0; a<n; a++)


{
Cin>>array2[a];
}

for( a=0; a<n; a++)


{
array3[a]=array1[a]+array2[a];
}
getch();

Q.No. 8 a) What type of information the following statement provides the Compiler:

float zara(int, float, char);

b) Write a program to draw circle of center(x,y) and radius r.

#include<stdio.h>
#include<graphics.h>
#include<conio.h>

int main(){
int gd = DETECT,gm;
int x ,y ,radius=80;
initgraph(&gd, &gm, "C:\\TC\\BGI");
/* Initialize center of circle with center of screen */
x = getmaxx()/2;
y = getmaxy()/2;

outtextxy(x-100, 50, "CIRCLE Using Graphics in C");


/* Draw circle on screen */
circle(x, y, radius);

getch();
closegraph();
return 0;
}
Help for the above program

In this program, we will draw a circle on screen having centre at mid of the screen and radius of 80
pixels. We will use outtextxy and circle functions of graphics.h header file. Below is the detailed
descriptions of graphics functions used in this program.

Function Description
It initializes the graphics system by loading the passed graphics driver then
initgraph
changing the system into graphics mode.
getmaxx It returns the maximum X coordinate in current graphics mode and driver.
getmaxy It returns the maximum Y coordinate in current graphics mode and driver.
outtextxy It displays a string at a particular point (x,y) on screen.
circle It draws a circle with radius r and centre at (x, y).
closegraph It unloads the graphics drivers and sets the screen back to text mode.

Anda mungkin juga menyukai