C Programming Lab Geca
C Programming Lab Geca
11 , }
12 .r eturn 0 ;
13 }
.;/ ,,,
I ...
I" 'I
I I
i!.,, . ..
, I
< > Q7 character pattern.cpp
QS.cpp QB 2.cpp X
1 ~include<stdio.h>
2 main ()
- {
I~
int n;
S'
printf ( "Enter n: \n" );
6
scanf ( "%d" ,&n);
for ( int i =l ; i <=10; i ++)
I{
}
printf ( "%d*%d=%d\n", n, i , n*i );
12 }
I
Ernfe r. ril
8
8*:1=8. 1
8 ', =16
8 = '
--------------------------------
V
~ {
for ( int row=l ; row<= S; row++)
~
{
for ( int column =S- row; column >=l ; column --)
{
printf ( " ");
}
1~ for ( int column =l ; column <= row; column++)
1 - {
12 printf ( "%d" , column );
13 }
14 f printf ( "\n" );
15 - }
16 } I
Compilation res ul ts - ..
- Errors: 0
_ w ~ -; ..,,,...Cl• n
I U B
iO
I UM-GCC 9.2.0 64-bit Releas1v f ~ ,,.. =
\ (globals) V
if] CJ
X X
sses < > Q5.cpp Q11 2.cpp
1 \#include<stdio. h>
2 main ()
- {
4 int n;
5, printf ( "Enter n : \ n" );
,I
6 scanf ( "%d",&n);
for ( int i =l ; i <= l0; i ++)
{
I
\ printf ( "%d*%d=%d\n ", n, i , n*i );
}
i
'I
'·'ii
\,
I
·:
(globals) V
cD CJ i1
X X X
( > Q5.cpp Q11 2.cpp Q12 for.cpp
1 ~inclu de<std io.h>
2 main ()
- {
int m, n;
printf ( "Enter value of m, n : II ) ;
scanf ( "%d%d",&m,&n);
for ( int i =m; i <= n; i ++)
{
I
-~ if ( i %2==0 )
\ {
I
-~M-
12
\!
I
!
I
i
}
printf ( %d is even \ n , i ); 11 11
13 \ else
\
{print f ( %d is · odd \ n", i );
11
I
\
~~-'
16
I
I
}
}
17
18 }
' I !1
I I I! I l
' I( 1, ' I
11 /·1/,,
0
/ 1 ,i/ii'i ! t I
0
lobals)
.}
:: o rm gg v'
v i
V
X
< > Q5.cpp Q11 2.cpp Q12 for.cpp X y
X
Q13 2.cpp
1 #in c lude <st dio. h>
2 main ()
- {
int m, n ;
printf ( " Enter value of m ., ,n , : " );
6 scanf ( %d%d ,&m,&n )) 11 11
7 while[tn<=nt]
{
!T if ( m%2==0 )
{ I
~fil-
12 }
Printf ( "%, , , '!i1l! I
', I , :
· · ' ' '
I
13 else 1 ''1 ''
1 - , { printf ( "%d is · odd\n" , m);
}
m++;
} ;
on So le X Close
••
Find Results - □-C-
Compile Log ✓ Debug @
-
- - -- - - -~ -.....-- ..7• ~ 'flllOOVV ne1p
i !] CJ
Classes < > power(x,n}.cpp x Q14.cpp
X
9
10 for ( int i =l ; i <= n ; i ++)
11[ {
12 r ;;;; r *x;
13 }
14
printf ( "pow(%d, %d) = %d" , x, n, r );
15
16
17 }
.. :
Vtew Project Execute Tools AStyle Window Help
I - ' -
tJ IZl
- - - ~~i 19
el GJ ·8 ii TDM-GCC 9.2.0 64-bit Releas , v
- ·I i]
i (globals)
- - - v/
,fJ CJ ii
Proiect Classes < > Q20 decimal to binary.cpp X
~ '~i~:.
b:int 1 ~incl ude<s tdio.h >
d: int 2 #in clude <math . h>
- main (){
4 int d, b=0, r , i =0;
5 print f ( Enter the decim al number : "); 11
11 16 }
\I
Ii
I'
l'
1\
\'
. , .. ·1 .
r rt. Resources dll Complle Log i...,.,. Debug 19 Find Results 8
~ ,,. ... ,_ !• -
I[] CJ ii
C\asses < > Q21 decimal to octal.cpp
d: int 1 ~ inc lud e<s tdio .h>
i: int 2 # i nc lud e <ma th . h>
- mai n (){
oct a\: int 4 int d, oct al=0, r , i =0;
r: mt s pri ntf ( "Enter the dec ima l number
:" ) ;
6 sca nf ( "%d " ,&d );
7
8 whi le ( d>0 )
I
{
10 r =d%8;
11 oct al=oct al+r *pow (10 , i );
12 d=d / 8;
13 i ++;
14 } .
Irt_o ..mc,il
....- at io n ces ul ts .- -
- - - - - - , i:-;:::;:! O
• : ~~~ .;;-_ :.~ ~ ~ ~ \
. . . . cumpile ·\- - Wc0r:n 1.nqi:i :
0 . c· ·\U:s acs\d hee.r -\O< >c-n
out.p ut. t 1.h,1r ~ct~; l:t\M 't
c coDE S\Q2 0 . . . , ~ '°
_ Out.p ~L s~z.e • . . _ ; 25
!)1J~'. 10"> i<iB
u.t.'Ja t
p 11· •w r'lOJect-cce-care-rc>01r .Asty1e Window Help
CJ = ~j >[) ~
··----~---- ~-~--~
~ -·-· \ 1g t\c ~ ·E:l i TDM-GCC 9.2.0 64-bit Releas, v ,,
L.i
~ .. - ·-- ~~--- --------- - - --------- -
\ (globals) V
V '
ifl CJ Iii
X
»iect ;: C\a:sses < > Q22 binary to decimal.cpp
· b.:,nt
":•
1 \#include<stdio. h>
2 #in c lude <math . h>
- main (){
,... ·:
I int 4 int d=0 , b, r , i =0;
·- ., r: int 5. printf ( " Enter the binary number : " );
6 s ca nf ( "%d 11
, &b) ;
7
8 while ( b>0 )
{
10 r =b%10;
11 d=d+r * pow ( 2, i );
12 1 b=b/ 10; ;
13 \ , . i ++;
14 } ' <' I I
t
Q23 octal to decimal.cpp
1 \#include< stdio. h>
2 #include<m ath. h>
- main (){
4 int d, octal , r , i =0;
t 0
5 printf ( Enter the binary number .• fl ) ,.
6 scanf ( "%d",&octa l );
7
8 while ( octal >0 )
{
10 r =octal%10;
11 d=d+r *pow{8, i );
12 octal=octa l/ 10;
13 i ++; I
14 }
15 printf ( "%d", d);
16 }
{] CJ li1
ses < > arrnstrong number.cpp X
16 if ( sum== nl )
{
11\
18
19
,printf ( "number is armstr~ng ''.) ; ,
'} ', "·,,''"',' '·,, ,\.1' ', ,,,,
21
22
23 }
{ printf ( " ,number is not ',
}
,I
'
t•
' ' /1 \1 ii I p •,
: . l I I
I
I,
1
j' i\'
iI
I
I I'
I
-I I '
'arn:.st~ong
,'·11,
L·\.;\
~ '' '
.' I '
' 1\ I
number u);
', I j, l I
II ;' I
' I • l
,11 ' 1•
pile Log ·. ✓ ' Debug