The document describes exercises on structures and strings in C programming. It defines a structure called _PLAYER to store details of players like name, date of birth, height and weight. It then shows how to define the structure, read and print records of multiple players from an array of _PLAYER structures. Functions are defined to find the tallest player, print names in descending order of height, check character cases, convert case of characters in a string, and compute operations on structures like distance between points.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
Final tagless. The topic strikes fear into the hearts of Scala developers everywhere—and not without reason. Final tagless allows developers to build composable Domain Specific Languages (DSLs) that model interaction with the outside world. Programs written using the final tagless style can be tested deterministically and reasoned about at compile-time. Yet the technique requires confusing, compiler-choking higher-kinded types, like `F[_]`, and pervasive, non-inferable context bounds like `F[_]: Concurrent: Console: Logging`. Many have looked at final tagless and wondered if all the layers of complexity and ceremony are really worth the benefits.
In this presentation, John A. De Goes provides a gentle and accessible introduction to final tagless, explaining what it is and the problem it intends to solve. John shows that while final tagless is easier to use than free monads, the technique suffers from a litany of drawbacks that push developers away from functional programming in Scala. John then introduces a novel approach that shares some of the benefits of final tagless, but which is idiomatic Scala, easy to explain, doesn’t need any complex type machinery, provides flawless type inference, and works beautifully across Scala 2.x and Scala 3.
Come join John for an evening of fun as you learn how to write functional code in Scala that's easy to test and easy to reason about—all without the complexity of free monads or final tagless.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
Final tagless. The topic strikes fear into the hearts of Scala developers everywhere—and not without reason. Final tagless allows developers to build composable Domain Specific Languages (DSLs) that model interaction with the outside world. Programs written using the final tagless style can be tested deterministically and reasoned about at compile-time. Yet the technique requires confusing, compiler-choking higher-kinded types, like `F[_]`, and pervasive, non-inferable context bounds like `F[_]: Concurrent: Console: Logging`. Many have looked at final tagless and wondered if all the layers of complexity and ceremony are really worth the benefits.
In this presentation, John A. De Goes provides a gentle and accessible introduction to final tagless, explaining what it is and the problem it intends to solve. John shows that while final tagless is easier to use than free monads, the technique suffers from a litany of drawbacks that push developers away from functional programming in Scala. John then introduces a novel approach that shares some of the benefits of final tagless, but which is idiomatic Scala, easy to explain, doesn’t need any complex type machinery, provides flawless type inference, and works beautifully across Scala 2.x and Scala 3.
Come join John for an evening of fun as you learn how to write functional code in Scala that's easy to test and easy to reason about—all without the complexity of free monads or final tagless.
Moore's Law may be dead, but CPUs acquire more cores every year. If you want to minimize response latency in your application, you need to use every last core - without wasting resources that would destroy performance and throughput. Traditional locks grind threads to a halt and are prone to deadlocks, and although actors provide a saner alternative, they compose poorly and are at best weakly-typed.
In this presentation, created exclusively for Scalar Conf, John reveals a new alternative to the horrors of traditional concurrency, directly comparing it to other leading approaches in Scala. Witness the beauty, simplicity, and power of declarative concurrency, as you discover how functional programming is the most practical solution to solving the tough challenges of concurrency.
Practical Class 12th (c++programs+sql queries and output) Aman Deep
Just download this and do some specific changes in the name section and roll no section . and submit it as it is to your teacher this will surely work and help you out your class 12th board practicals exam . no worries ! ENJOY :) !
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
Here's my Computer Science Board Practical File. I hope you find it as useful as it was to me.This file is however of CBSE class 12th 2020-2021 syllabus.
1. Perform Linear Search and Binary Search on an array.
Descriptions of the programs:
Read and array of type integer.
Input element from user for searching.
Search the element by passing the array to a function and then returning the position of the element from the function else return -1 if the element is not found.
Display the positions where the element has been found.
2. Implement sparse matrix using array.
Description of program:
Read a 2D array from the user.
Store it in the sparse matrix form, use array of structures.
Print the final array.
3. Create a linked list with nodes having information about a student and perform.
Description of the program:
Insert a new node at specified position.
Delete of a node with the roll number of student specified.
Reversal of that linked list.
4. Create doubly linked list with nodes having information about an employee and perform Insertion at front of doubly linked list and perform deletion at end of that doubly linked list.
5. Create circular linked list having information about a college and perform Insertion at front perform Deletion at end.
6. Create a stack and perform Pop, Push, Traverse operations on the stack using Linear Linked list.
7. Create a Linear Queue using Linked List and implement different operations such as Insert, Delete, and Display the queue elements.
Moore's Law may be dead, but CPUs acquire more cores every year. If you want to minimize response latency in your application, you need to use every last core - without wasting resources that would destroy performance and throughput. Traditional locks grind threads to a halt and are prone to deadlocks, and although actors provide a saner alternative, they compose poorly and are at best weakly-typed.
In this presentation, created exclusively for Scalar Conf, John reveals a new alternative to the horrors of traditional concurrency, directly comparing it to other leading approaches in Scala. Witness the beauty, simplicity, and power of declarative concurrency, as you discover how functional programming is the most practical solution to solving the tough challenges of concurrency.
Practical Class 12th (c++programs+sql queries and output) Aman Deep
Just download this and do some specific changes in the name section and roll no section . and submit it as it is to your teacher this will surely work and help you out your class 12th board practicals exam . no worries ! ENJOY :) !
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
Here's my Computer Science Board Practical File. I hope you find it as useful as it was to me.This file is however of CBSE class 12th 2020-2021 syllabus.
1. Perform Linear Search and Binary Search on an array.
Descriptions of the programs:
Read and array of type integer.
Input element from user for searching.
Search the element by passing the array to a function and then returning the position of the element from the function else return -1 if the element is not found.
Display the positions where the element has been found.
2. Implement sparse matrix using array.
Description of program:
Read a 2D array from the user.
Store it in the sparse matrix form, use array of structures.
Print the final array.
3. Create a linked list with nodes having information about a student and perform.
Description of the program:
Insert a new node at specified position.
Delete of a node with the roll number of student specified.
Reversal of that linked list.
4. Create doubly linked list with nodes having information about an employee and perform Insertion at front of doubly linked list and perform deletion at end of that doubly linked list.
5. Create circular linked list having information about a college and perform Insertion at front perform Deletion at end.
6. Create a stack and perform Pop, Push, Traverse operations on the stack using Linear Linked list.
7. Create a Linear Queue using Linked List and implement different operations such as Insert, Delete, and Display the queue elements.
Let us C (by yashvant Kanetkar) chapter 3 SolutionHazrat Bilal
All rights reserved. No part of this slide
may be reproduced, stored in a retrieval
system, or transmitted, in any form or by
any means, without the prior permission.
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
1sequences and sampling. Suppose we went to sample the x-axis from Xmin to Xmax using a
step size of step
A)Draw a picture of what is going on.
B) Write a expression for n the total number of samples involved (in terms of Xmin, Xmax and
step)
C) Write out the sequence of x-samples
D) Write a direct and general expression for xi that captures the sequence
E) Write a recursive expression for the sequence
F) Write a program to compute and store the x-samples over the range -5x5 using a step size of
0.1 do everything in main ()
2 . We talked about the following string functions that are available in C (as long as you include
string.h):
int strlen(char str[])
void strcpy(char str1[], char str2[])
void strcat(char str1[], str2[])
Write your own versions of these functions; for example: int paul_strlen(int char str[]). Hint: for
your version of the strlen function, start at the first character in the array and keep counting until
you find the ‘\\0’ character (use a while loop for this). Note: Use your version of the strlen
function in the strcpy and strcat functions.
9. We want to insert a number into an array.
(a) Formulate the problem mathematically with two sequences: x and y. (b) Write a function of
the form:
insertNumIntoArray(int n, int array[], int num, int index)
The function inserts num into the array at the specified index. The rest of the array then follows.
For example, if num = 9 and index = 3 and array = [7 2 8 8 3 1 2] then the function will produce:
array = [7 2 8 9 8 3 1 2]
Note: assume that array is properly dimensioned to have at least 1 extra space for storage.
10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a
specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20],
then the result will be
array: [50 70 10 60 20]
11. Repeat #2 by for an insert operation where we are inserting several values into the array. The
function should be of the form:
int insertArrayIntoArray(int n, int inArray[],
int nInsert, int insertArray[], int outArray[], int index)
The dimension of outArray is returned (explicitly). For example:
inArrayarray: [7 2 8 6 3 9]
insertArray: [50 60 70]
index: 2
outArray: [7 2 50 60 70 8 6 3 9]
Assume that outArray is large enough to hold all n + nInsert values.
Solution
#include
//Simulates strlen() library function
int paul_strlen(char str[])
{
int l;
for(l = 0; str[l] != \'\\0\'; l++) ;
return l;
}
//Simulates strcpy() library function
void paul_strcpy(char str1[], char str2[])
{
int c;
for(c = 0; str1[c] != \'\\0\'; c++)
str2[c] = str1[c];
str2[c] = \'\\0\';
printf(\"\ Original String: %s\", str1);
printf(\"\ Copied String: %s\", str2);
}
//Simulates strcat() library function
void paul_strcat(char str1[], char str2[])
{
int i, j;
for(i = 0; str1[i] != \'\\0\'; i++) ;
for (j = 0; str2[j] != \'\\0\'; i++, j++)
{
str1[i] = str2[j];
}
str1[i] = \'\\0\';
printf(\"\ Concatenated String: %s\", str1);
}
int main()
{
char data1[20], data2[20];
pri.
2. Q. 1
Define a structure data-type named
_PLAYER which has the following
members:
Name: A string of 30 characters.
DOB: A string of 10 characters.
Height: A floating point number.
Weight: A floating point number.
Spring Programming and 2
4. Q. 2
Write a main program which
reads records of N players
(N to be read from the
keyboard) in an array of
_PLAYER and prints their
names and dates of birth.
Spring Programming and 4
6. Reading and Printing
main() printf("DOB as dd/mm/yyyy? n");
{ _PLAYER pl[MAX_NO]; %[^n]",pl[i].DOB);
scanf(“
int N,i;
printf("Height (cm.) and Weight (kg) ? n");
printf("Give the number of players n");
scanf("%d",&N); scanf("%f%f",&pl[i].Height,&pl[i].Weight);
}
for(i=0;i<N;i++) printf("Data read n");
{ printf("Input the %d th player n",i+1);
printf("Name? n ");
printf("Printing Name and Dates of Births n");
scanf(“ %[^n]",pl[i].Name);
for(i=0;i<N;i++)
{
printf("Player[%d]--> %s %s n",i,pl[i].Name,pl[i].DOB);
} Spring Programming and 6
7. Q. 3
Write a function which takes
an array of _PLAYER as a
parameter and returns the
tallest player by deleting the
player from the list and
adjusting the array by moving
the elements upward.
Spring Programming and 7
8. Function Implementation
_PLAYER tallest_player(_PLAYER p[ ], int N)
{ Computing the array index for the tallest player
int i;
float maxHeight=-1;
int maxPos;
_PLAYER tmp;
for(i=0;i<N;i++) tmp=p[maxPos];
{ for(i=maxPos+1;i<N;i++)
if (p[i].Height > maxHeight)
{ Return Tallest Player p[i-1]=p[i];
maxPos=i; return(tmp);
maxHeight=p[i].Height; }
}
} Spring Deleting a player and readjusting array
Programming and 8
9. Q. 4
Use this function to print the
Names of players in the
descending order of their
heights.
Spring Programming and 9
10. Printing in ascending order of heights
main() printf("DOB as dd/mm/yyyy? n");
{ _PLAYER pl[MAX_NO]; %[^n]",pl[i].DOB);
scanf("
int N,i;
_PLAYER tallest; printf("Height (cm.) and Weight (kg) ? n");
printf("Give the number of players n");
scanf("%f%f",&pl[i].Height,&pl[i].Weight);
scanf("%d",&N); }
printf("Data read n");
for(i=N;i>1;i--)
for(i=0;i<N;i++)
{ { printf("Input the %d th player n",i+1);
tallest=tallest_player(pl,i);
printf("%s Height=%f n",tallest.Name,tallest.Height);
printf("Name? n ");
}
scanf("%[^n]",pl[i].Name);
printf("%s Height=%f n",pl[0].Name,pl[0].Height);
}
Spring Programming and 10
11. Q. 5
(a)Write a function isLC( )
which takes a character as
an input and returns 1 if it is
a lower case alphabet else 0.
(b)Write the corresponding
function isUC( ) for checking
an upper case alphabet.
Spring Programming and 11
12. Functions for checking alphabet cases
int isLC(char c) int isUC(char c)
{ {
if((c>='a') && (c<='z')) if((c>='A') &&
return 1; (c<='Z'))
else return 1;
return 0; else
} return 0;
}
Spring Programming and 12
13. Q. 6
Write a function toLC( ) which
takes a string as an input and
replaces all the Upper Case
alphabets to lower cases
within it. The function also
returns the number of
changes it made.
Spring Programming and 13
14. int toLC(char s[ ])
{
int i, nChange=0;
for(i=0; s[i]!=0; i++)
{
if ((s[i]>='A') && (s[i]<='Z'))
{
s[i]=s[i]-('A'-'a');
nChange++;
}
}
return nChange;
}
Spring Programming and 14
15. Q. 6-a
• Write the recursive
implementation of toLC( )
for converting Upper
Cases to Lower Case.
Spring Programming and 15
16. int toLC(char s[ ],int pos)
{
if(s[pos]==0)
return 0;
else
if((s[pos]>='A') && (s[pos]<='Z'))
{
s[pos]=s[pos]-('A'-'a');
return 1+toLC(s,pos+1);
}
else
return toLC(s,pos+1);
}
Spring Programming and 16
17. Q. 7
• Write a function
complementString( ) which
complements an input
string by changing the
cases of its alphabets. The
function also returns the
number of changes.
Spring Programming and 17
18. nt complementString(char s[ ])
int i,nChange=0; If (isLC(s[i]))
{
i=0; s[i]=s[i]+('A'-'a');
while(s[i]!=0) nChange++;
{ };
if (isUC(s[i])) i++;
{ }
s[i]=s[i]-('A'-'a'); return nChange;
nChange++; }
}
else
Spring Programming and 18
19. Q. 8
• (a) Write a function absd( ) which
takes a value in double data-type and
returns its absolute value in double.
• (b) Write a function expd( ) which
computes ex for an input variable x
(of double data type) by computing
the following series summation with
an accuracy of .0001.
ex= 1 + x/1! + x2/2!+ x3/3!+…………..
Spring Programming and 19
20. double expd(double x)
{
double sum,term;
double error_bound=.0001;
ouble absd(double x) int i;
f(x<0) return -x; term=1;
else return x; sum=1;
i=0;
while(absd(term)>error_bound)
actorial is not {
omputed directly. i++;
term=term*x/(double) i;
Xn/n! sum=sum+term;
}
return(sum);
Spring Programming and 20
21. Q 8 (contd.)
• Write a program which
computes exponential of
values (to be read from the
keyboard) in an infinite loop.
Spring Programming and 21
23. Q. 9
• Write a function which returns square root
of a floating point value with an accuracy
of .00001, following the Newton-Raphson
method.
• Newton-Raphson method:
Solve: f(x)=0
Iteration: xn+1= xn- f(xn)/f’(xn)
• Newton-Raphson method for square root:
f(x)=x2-a
Iteration: xn+1= xn- (xn2 –a)/2xn
Spring Programming and 23
25. Q.10
• (a) Define a structure _PNT
which has x-coordinate and y-
coordinate (both of float data-
type) as its members for
representing a point in a 2-D
space.
• (b) Write a function dist() which
takes two points and returns the
distance between them.
Spring Programming and 25
26. typedef struct{
float x,y;
} _PNT;
float dist(_PNT a, _PNT b)
{
float d;
d=(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
if(d>0)
return((float)sqrt((double)d));
else
return(0);
} Spring Programming and 26
27. Q. 10
• (c) Define a function checkCircle( ) which
takes center and radius of a circle and a
point p as inputs and returns -1, 0 or 1 if p
is outside, or, on its perimeter or inside
the circle respectively. Use the function
dist( ).
• (d) Write a main( ) function to read center
and radius of a circle and a query point q.
The program should print whether the
point is outside or inside or on the circle.
Spring Programming and 27
28. int checkCircle(_PNT c, float R, _PNT p)
{
float d;
d=dist(c,p);
if(d>R) return (-1);
else if (d<R) return(1);
else return(0);
}
Spring Programming and 28
29. Read the center of circle
40 50
main( )
{ Read the radius of circle switch(flag)
10
_PNT oc,p; {
float R; point
Read a
case 1: printf("Inside n");
35 25
int flag; break;
Outside
case -1: printf("Outside n");
printf("Read the center break;
n"); case 0: printf("On circle n");
scanf("%f%f",&oc.x,&oc.y); break;
printf("Read the radius default:
n");
printf("?? n");
scanf("%f",&R);
}
printf("Read a point n");
}
scanf("%f%f",&p.x,&p.y);
flag=checkCircle(oc,R,p);
Spring Programming and 29
30. Q. 11
• (a) Write a function mean( )
which takes an array of N
floating point numbers and
computes their mean.
• (b) Write another function
named sd( ) for same input
for computing standard
deviation. Use mean( ).
Spring Programming and 30
31. oat mean(float x[ ],int N) float sd(float x[ ],int N)
{
nt i; int i;
float sum=0; float sum=0, sqrsum=0;
float mu, var, sigma;
for(i=0;i<N;i++)
sum+=x[i]; for(i=0;i<N;i++)
sqrsum+=x[i]*x[i];
eturn(sum/(float)N);
mu=mean(x,N);
var=sqrsum/(float) N-mu*mu;
if(var>0)
sigma=(float)sqrt((float)var);
else
sigma=0;
Spring Programming and
return(sigma); 31
32. Q. 11 (contd.)
• Write a main program to read
N values in an array and
compute their mean and
standard deviation.
Spring Programming and 32