0% found this document useful (0 votes)
5 views21 pages

PPS Assignment

The document contains a series of programming exercises and examples primarily focused on basic arithmetic operations, control statements, and loops in C programming. Each section includes a brief description of the task, the corresponding code, and expected output. The exercises cover various topics such as addition, subtraction, multiplication, division, and checking for prime numbers or palindromes.

Uploaded by

shubh2006s
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)
5 views21 pages

PPS Assignment

The document contains a series of programming exercises and examples primarily focused on basic arithmetic operations, control statements, and loops in C programming. Each section includes a brief description of the task, the corresponding code, and expected output. The exercises cover various topics such as addition, subtraction, multiplication, division, and checking for prime numbers or palindromes.

Uploaded by

shubh2006s
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

<br>

TNDEX
[Link] of Broxarn Date S9natume
o tuwo hunhens
add
QFox Subztxacton af twon
3 fox nud&Scalon otws numabees!
4
Divian of
fuo hlambets
5
indin RerriindeH afen chvkida

ompaing humuimg Simble if

9oran uing hested if


Dsbaying Counts wsing for Joop
lo
|)Displaying Couts using Rle Roop
ng do-ole looh
1Q Dpla ying Countz si
Bogan kor tRe fi bonaci Sedes
3
ogram to Bindactoyia ofo Nbol
4 ogxam to checla Psime Mmbe
1s
Names
l6 Rrogan fog Revesea
u
hogn for checb Relindrome Nnbor
o Num
roqram fov Sun o Digita
is
Nugiber
19 sogsam for Suab Two
o Paogarn for find agest of Three Mamben
<br>

1:>
Woite a program to add tuUo nunbers:

#irclude <stdio-h
<
# jncsude cohio-h>
int majn()
int a, b
n
print"Enten he two bes to add:;
Scanfl"%d 2.J Ba, d);
e o
int Sum -atb;
prind("TRe sum of te nlnbons is 7.4, sum);
getchU;
tetwin 0;

Enten tRe two rumbes to addi1, a


o 3
Re Sum the numbes is
<br>

Pg-c&

Waite a pcgbaka to &ubstrad tuwo numbes

#incude <stdio h>


#include <sttcoio-h>
int main0
int a, b, difenercej
poind("Enten the Frst numbeni"):
kcanf(nd ", a);

Žcan("h7d, b);
e
þrint(n Eter kecond numben:");

difeence a-b;
pint{("n TRe denee botf nwkewis/.J
getc); diforoet
Qutbut:>
Enten the frst ntnber: lo
Enten
tRe&econd nwnber: 7
TRe diforee of both niunber is
3
<br>

Pa.o3

Waite a pangoama to mwtiply two ninbors.

Pcgvan>
#include <stdio-h
#inckude ecohio-h
int maih ()
int a, b, þaodut;
þpindf('Bter Re tuo nlnbew to muliblyi

þoodut= a*b;
pint("in tRe þraduct
geth);
o Re two nwnbeu istd bod

eton 0; 7

Erte the tso nnbes to mulipyi4,3


Re product the two numbers
i
<br>

gran 4
wot a program for divikion o too runbors
Regrami
#incude <stdio-h
*include < Conio-h
int main)
{inta, b, divižion,
þrint("Enin
h divi dehnd
:");
Starfl4", da);
pirl"Ester Re diisoa:);

division:
a/bi
þainb("9n the answer for younoivis ioh ia /:d?
getck(0; divižicJ;
stetuo;
Outputi>
Ertet the dividend: a8
Ende the divisor :78
yowr divisioh i8 y.
TRe answet for
<br>

rcgram
5>
Woite a þacgram
to find remaihden
When two nuhnbers divided.
d
ae
Bogrami
#include <Stlio.h>
<
include cohio-h>
int maih)
(int a, b Hemainde;
þoirt("te1 the divisen:);
Scanf('d", ka);
þrirt/(/nEten the dvidod");
šanf d", db);
Hernalndo
pbtajned
þirt(a n"The is/d,4aynt
getek;
1eturn0;
Outhut:>
EnteH the diviber:
Ente dividend: 13
th
TEe merajnder obtined isl
<br>

woite a progtam fo the combaÚlon of too


hunbers using sinple contal ktatiment
#inude <stdio-h>
#include<conio-h
int main()
(inta, b;
psird('Ete the vale ofa:");
Scanfl"d" da);
print Gten th valu f bi);
Scarfld ", db);
8aB
þoinl%aiu gretor than b'J;

þrint(a a and b both ahe cqual);

getch0;

Output:>
Ertey theValu of a: 7
Erten the valu o
b:5
a is 9teten than b.
Pg:o1
<br>

Wite a þrog san fox


nunbe usig ebe -contol Statemet
Regaam
#incude stdio-h>
#incuck <conio- hz
irt main()
int a, bj
pinsf( bte he value
ofa:;
sall' d", da);
Sar ('hd db); ,
lb)í a
in (n is gratt ker
b;
dae{þinf n a is not geater Han
b);
get;n :

Erte
b
a is goester thah
<br>

&tatement
Waite a þrcgram using nested if contl

#inlude <stdio-h
incude <conio-h>
# majl()
int
(int score)
pin Entet yor am Score:)
Sarf( d" lscore):
Rscore>-5o)
þašsed! );
pirdfu
Excellarnt, you Soed So [Link] ');}
{
pir("n
se
else paind(* %u
fidedw;
printl"Good lucb for yon naxt atembt); o

gekk(0;
etnO;
Outputi>
youH erem scose: 3
En
pas3e
You þassed! d!o
You scored so we
ll.
Excellot,

chorce
<br>

Pgo9

ogran9:>
Woite a þrogram using bwitok ase conbol statmt!

graniude <stdioh
nclude <cohjo.h
int main )
(int day
your ophon: \nl:Monday lh 8-Lcadag
þsintf ("Chaoße yowr
print"bten yown chei ce: ");
Suith (dqy){

breab;
Gabea?

byeab

þrindlWottavalid entey .cRoose los2°);

getko;

choose youY Opior:


1-Monday

yor
Eiten choice: !
Mondy
<br>

Pg-o

|Pogram|0:
Wsite a pxogram Uing fox looþ Cotal sttat
to Displey conts ubto lo.
Pbogrami
##inude cstdio-h
h
# include <cohio-
int majn)
inti;
fos (i-0;,i0; i++)

gekck 0; 7

Outputi>

3
5
6

9
<br>

Progan 11:>
Waite a pogn to display Couhts ubto lo
using wklu Contl btaement.
by
þrograni
#include cstdio h
# include cconi-h
int main )
(int i=0;
wRle (ize lo)

getel0;"
sehuinO;

Output>

5
<br>

Pg-1a

Progwa
px09ram to brint multplcatton table
a poogran
Waite
contbol statement.
of 5 using do- wRle loop
Poogram:>
#include cstdioh
<
# include corio-h
int main)
Eint i-5;
do
pxint("[Link]);
i-i+57

1etuin0;

Output i>
5
15

3o
35
40
45
50
<br>

B.13

|Proq ram13:>
Weite a
a þrogam for te fi bonacci Seiz

#include <stdioh
+indude <cohio.h>
Void main)
int na =
O,b:l, hext,
nti)
Cls);
þint('Enter nunber of tesom;");

fos(i-I,i<h; itt)f
þain4 a);
hexf=atb;
a=b,
b:next
ge tek1;

3 o tems:9
Ehten numbe
Outpu> iboracci Seva:0|12358 13
<br>

Progbam 14:>
Weite a progjan to nd factaial
a
unbers

#rudeestdio-h>
#inude <conio.h>
int factovial (nt n)
(h-:0||nz)
yetun |;
else
eton*facoial(n-1);

Void main 0{

hf( The fac toial


fdia4; aunber,
factsiallunked;
gettk(;

Otput Enten te nsnboi to fimd tte factosial:5


Py*
<br>

15

15.>
a prog ham to chech Pime
Woite
Nunbet

tindude <stdio-h>
+incude <conúo.h>
Void ain)
intnmi,flag- 0;
clsco):
Printl"Eter a nmbe:"))
if(nume-1)
a
pintf(No t Poime Number;
else
for(i:9; izz huun /2; i++)

if(num. ie-0)

bresa

iF(Elay
-0)
hiž( Bime Manben);
a Prime
þintf("wot Mumbe):

JekR() a
Outpu j) Ente nunbet7
Prime Waynben

Eg:a)erten a numbe: l0
Nota Bime Vunbet
<br>

Bagram; l6:
a
Wite a
þrogtam to reNeLe hwnbe
Psogvam'
indude <stdio-h>
#
inlude <conio-h>
Void main)

int num, teveNse =


0, Yem,
carscr);
Prindl"Ente a nunbeH: ");
Sanl'% s", (hum);
wfse(nn! - o)

evese =
yevesse oten;

Qtput Enter
Entey a nhbei 507
Revesaed nimbe:105
<br>

Psogan
check balindaome
Wite a a þroqtam to add
Nmber
|Recqrami
tinchude<Stdio·h
+indudecconio.h
Void main)

int nm, Ovigina, evebe -O, Yem;


cAas0;
þird"Ent number:");
Stan(%d &num);

kilenum!-o)
em=num (o;

humnwkn/lo}

i(oiginal-r yevoue)
priv (alindrome Naber);

a Ralindoeome Maribe);
pintC"Not
getko;

Qutput g) Erton a nwnbe:12|


Palindme Nunber

Not a Palind ome hembey


<br>

18

Wite a program for sun of digits


a
nunbet
Proqza:
#incade <stdio-h>
#indude <conio- h

Void maJn)

int nu, Suhn=O, Yem}


prirt{("tor a number.):
Stanfl"hd;Bhm
wkilelnn,-0)

Sum Swntrem;

pisfl'um o digita-d" Sun);


getto:

Outputr E:) Gtes a nnben:A34

Eg:2) Eo a
nuumbe: Go7
<br>

ogram9:>
Waite a prcgam for Swap too
humber UBig Thd Variable
Progran;
iude <stdio-h>
+incide < coNo-h>
Void mainl)

nt a, ben;

prt("énten too humbes:");


Scan('% d J, ka, (b);
tenp=a,
a -b;
b-tenp;
Prifftor Suwapingin2;
þila-dh betd,a. b);
getk0;

Outputi Eit
Entstw nnbos'. 5 10
Ater Suooa þing
a: lo, b5
<br>

Pbogat
wst aa prgam to
fnd Sagst
Woit
sree
unbes
Pbegani
#include<Stdio.h>
#indude e Conioh>
Void main)
nt a
b, C

birt"Enty tree humbess:"


Sanyld d.s, &a, &b, lcl;
(a >-b la3- )
þint"agest nen berd;a);

-
Pirt(gst numbor d; b);
elne
brit( largest umbe /. d
;J;

Outout Erten thoee numbers: lo 25 15


Lugst nmben 25

You might also like