Sie sind auf Seite 1von 31

Assignment-1

Date
Author :- Raja Yadav

Que. 1 :- write a programme input any two number and find the multiplication of both
number?

Solution :-

#include<stdio.h>

#include<conio.h>

void main()

int a,b,c;

clrscr();

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

scanf("%d",&a);

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

scanf("%d",&b);

c=a*b;

printf("\n display multiplication of both number=%d",c);

getch();

}
OUTPUT:-
Assignment-2

Date
Author :- Raja Yadav

Que. 1 :-write a programme input any number and find the square value?

Solution :-

#include<stdio.h>

#include<conio.h>

void main()

int m,n;

clrscr();

printf("\n enter any number="); scanf("%d",&n);


m=n*n;
printf("\n display square value=%d",m);

getch();

}
OUTPUT:-
Assignment-3

Date
Author :- Amit Sahu

Que. 1 :- write a programme input any two number and find the addition, subtraction,
multipication and division using mathametical operator
Solution :-
#include<stdio.h>

#include<conio.h>

void main()

int a,b,c,s,m,n;

clrscr();

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

scanf("%d",&a);

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

scanf("%d",&b);

c=a+b;

s=a-b;

m=a*b;

n=a/b;

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

printf("\n display subtracation=%d",s);

printf("\n display multipiction=%d",m);

printf("\n display division=%d",n);

getch();
}
OUTPUT:-
ASSINGMENT-4

DATE:-
AUTHOR:- Amit Sahu
QUS:-WRITE A PROGRAM INPUT ANY THREE NUMBER AND FIND THE BIGGEST
NUMBER USING NESTED IF SATEMENT.
SOLUTION:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("\n enter any three no=");
scanf("%d %d %d",&a,&b,&c);
if(a>b && a>c)
{
printf("\n a is biggest value");
}
if(b>a && b>c)
{
printf("\n b 3 biggest value");
}
if(c>a && c>b)
{
printf(" c is biggest value ");
}
getch();
}
RESULT:-
Assignment-5
Date
Author :- Raja Yadav

Que. 5 :- write a programme input any Number and display this massae.

1. “Good Morning”
2. “Good Afternoon”
3. “Good Evening”
4. “Sweet Dream”
5. “Good Night”

“ Invalid option please try again using nested else if statement

Solution :-

#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("\n enter any option=");
scanf("%d",&n);
if(n==1)
printf("\n good morning");
else if(n==2)
printf("\n good afternoon");
else if(n==3)
printf("\n good evening");
else if(n==4)
printf("\n sweet dream");
else if(n==5)
printf("\n good night");
else
printf("\n invalid option please they again");
getch();
OUTPUT:-
Assignment- 6

Date:-
Author :- Amit Sahu
Que. 1 :- write a programme input any Number and Display this massag using Swith
case statement.

Solution :-

#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("\ enter any option=");
scanf(" %d",&n);
switch('a')
{
case1:
printf("\n good morning");
break;
case2:
printf("\n good afternoon");
break;
case3:
printf("\n good evening");
break;
casr4:
printf("\n sweet dream");
break;
case5:
printf("\n good night");
break;
default:
printf("\n invalid option");
}
getch();
}
OUTPUT:-
ASSINGMENT-7

DATE:-
AUTHIR:- Amit Sahu
QUS:- WRITE A PROGRAM PRINT THE 1 TO 10 SERIZE BUT DUS NOT PRINT DIGIT
OF 7 AND USING FOR()LOOP,IF()CONDITION AND BRECK STATEMENT.

SOLUTION:-

#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
for(n=1;n<=10;n++)
{
if(n==7)
{
break;
}
printf("%d\n",n);
}
getch();
}
OUTPUT
ASSINGMENT-8

Date:-
Athor:- Amit Sahu
Que.:-Write a program input any no.and display multiplication table using for loop

SOLUTION:-

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

void main()
{
int n,m,i;
clrscr();
printf("\n enter any no=");
scanf("%d",&n);
for(i=1; i<=10; i++)
{
m=n*i;
printf("%d \n",m);
}
getch();
}

OUTPUT:-
ASSINGMENT-9

Date:-

Author:-Amit Sahu

QUS:- write a program this pyramid using for loop.

Solution:-

#include<stdio.h>

#include<conio.h>

void main()

int i,j;

clrscr();

for(i=0;i<=5;i++)

for(j=0;j<=i;j++)

printf(" *");

printf("\n");

getch();

}
OUTPUT:-
ASSINGMENT-10

Date:
Athor:- Amit Sahu
Que: Write a program to print this pyramid using for loop.

SOLUTION:-

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1;i< 5;i++)
{
for(j=1;j<=1;j++)
{
printf("%d",&j);
}
printf("\n");
}
getch();
}

OUTPUT:-
Assignment:-11

Date:-
Author by :- Amit Sahu
Que.:- write a program input any number and display multiplication table using while loop.
Solution:-

#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,i;
clrscr();
i=1;
printf("\n enter any number=");
scanf("%d",&n);
while(i<=10)
m=n*i;
printf("%d\n",m);
i++;
}
getch();

result:-
ASSINGMENT-12

DATE:-

AUTHOR:- Amit Sahu

QUS:-WRITE A PROGRAM INPUT ANY BASE NUMBER AND FIND THE FACTORIAL
VALUE AND USING RECURSION FUNCTION.

SOLUTION:-

#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

int a,b,c;

clrscr();

printf("\n enter any base value=");

scanf("%d",&a);

printf("\n enter any power value=");

scanf("%d",&b);

c=pow(a,b);

printf("\n display calculated value=%d",c);

getch();

}
OUTPUT:-
ASSIGNMENT - 13

AUTHOR NAME :- Amit Sahu

DATE:-

QUE.WRITE A PROGRAM INPUT ANY SENTENCE AND FIND OUT LENGTH LOG
THIS SENTENCE AND USING STRLEN FUNCTION.

SOLUTION:-

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

char n[15];

int l;

clrscr();

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

scanf("%s",n);

l=strlen(n);

printf("\n display length of string=%d",l);

getch();
}
Output:
Assignment-14

AUTHOR:- Amit Sahu


DATE:-
Qus:- write a program input a program input any two stering and both string are compare
and display message of both are equal string and both are not equal string using strcmp
function.
Solution:-
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[10], b[10];
int l;
clrscr();
printf("\n enter a first string=");
scanf("%s", &a);
printf("\n enter a second string=");
scanf("%s", &b);
l=strcmp(a,b);
if(l==0)
{
printf("\n both are equal string");
}
else
printf("\n both are not equal string");
}
getch();
output:-
ASSINGMENT-15

DATE-
AUTHOR:- Amit Sahu
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()
{
int a,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

AUTHOR- Amit Sahu


DATE-

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: 17

DATE –
AUTHOR- Amit Sahu
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:

-
ASSIGNMENT: 18

Date:
Athor: - Amit Sahu
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

AUTHOR:- Amit Sahu


DATE:-
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

AUTHOR – Raja Yadav


DATE -

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:-