Sie sind auf Seite 1von 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:-

Das könnte Ihnen auch gefallen