0% found this document useful (0 votes)
65 views12 pages

Assignment: 17

The document contains summaries of 5 programming assignments: 1) A program to calculate the area of a rectangle using call by value. 2) A program to calculate the addition of two numbers using call by value without returning a value. 3) A program to calculate the square of a number using call by value without returning a value. 4) A program to calculate the factorial of a number using recursion. 5) A program to store and display student data using a union.

Uploaded by

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

Assignment: 17

The document contains summaries of 5 programming assignments: 1) A program to calculate the area of a rectangle using call by value. 2) A program to calculate the addition of two numbers using call by value without returning a value. 3) A program to calculate the square of a number using call by value without returning a value. 4) A program to calculate the factorial of a number using recursion. 5) A program to store and display student data using a union.

Uploaded by

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

ASSIGNMENT: 17

DATE – 21/12/18

Q. Write a program input any lenth and width and find the area of rectangle using call by value(pass the
value and return the value)

Solution-

#include<stdio.h>

#include<conio.h>

void main()

int area (int,int);

int lenth,width,c;

clrscr();

printf("\n enter any lenth=");

scanf("%d",&lenth);

printf("\n enter any width=");

scanf("%d",&width);

c= area (lenth, width);

printf("\n area of rectangle=%d",c);

getch();

int area (int x,int y)

int z;

z= x * y;

return(z)}A
Output:-

-
ASSINGMENT-15

DATE- 03/01/19

QUS:- WRITE A PROGRAM INPURT ANY VALUE AND FIND THE SQUARE VALUE
AND USING CALL BY VALUE (RULE2) PASS THE VALUE AND NOT RETURN THE
VALUE.

SOLUTION:-

#include<stdio.h>

#include<conio.h>

void Add (void);

void main()

clrscr();

Add();

getch();

void Add()

inta,b,c;

printf("\n enter a first no=");

scanf("%d",&a);

printf("\n enter a second no=");


scanf("%d",&b);

c=a+b;

printf("\n addition=%d",c);

RESULT:-
ASSIGNMENT-16

DATE-19/02/2019

WRITE A PROGRAM INPUT ANY VALUE AND FIND THE SQUARE


VALUE AND USING CALL BY VALUE (RULL 2) PASS THE VALUE AND
NOT RETURN THE VALUE.

SOLUTION.

#include<stdio.h>
#include<conio.h>
void square(int);
void main ()
{
int a;
clrscr();
printf("\n enter any no=");
scanf("%d",&a);
square (a);
getch();
}
void square(int x)
{
int b;
b=x*x;
printf("\n square value=%d",b);
}

Ouput:-
ASSIGNMENT:18

Date:21\12\2018

Que:- write a program input any no and fined the factorial value and using recursion function .

solution

#include<stdio.h>

#include<conio.h>

void main()

int a, i, fv= 1;

clrscr();

printf("\n enter any no=");

scanf("%d",& a);

for(i=1; i<=a;i++)

fv = fv*i;

printf("\n factorial value =%d", fv);

getch();

}
Output:
ASSINGMENT-19

DATE:- 15\02\2019

QUS:- WRITE A PROGRAM INPUT ANY TWO VALUE/ANY VALUE AND


DISPLAY THIS VALUE AND USING UNION.

SOLUTION:-

#include<stdio.h>

#include<conio.h>

union student

int a,b;

} value;

void main()

clrscr();

printf("\n enter a no of a=");

fflush(stdin);

scanf("%d",&value.a);

printf("\n enter a number of b=");

fflush(stdin);

scanf("%d",&value.b);
printf("\n value a=%d",value.a);

printf("\n value b=%d",value.b);

getch()

RESULT:-
ASSIGNMENT 20

DATE - 19/02/2019

WRITE A PROGRAM INPUT STUDENT INFORMATION IN “TEXT FILE”


“STUDENT DAT” AND USING WRITE MODE.

SOLUTION:-

#include<stdio.h>
#include<conio.h>
void main()
{
int roll;
char name[20],opt;
FILE *fpt;
fpt=fopen("student.dat","w");
clrscr();
do
{
printf("\n enter roll no=");
scanf("%d",&roll);
printf("\n enter name=");
scanf("%s",&name);
fprintf(fpt,"%d %s\n",roll,name);
printf("\n do you want to input any record=(y/n)");
fflush(stdin);
scanf("%c",&opt);
}
while(opt=='y'|| opt=='y');
fclose(fpt);
getch();
}

OUTPUT:-

You might also like