0% found this document useful (0 votes)
14 views14 pages

C Programming Lab Geca

Uploaded by

dheerajku1st
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)
14 views14 pages

C Programming Lab Geca

Uploaded by

dheerajku1st
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/ 14

X

< > Q7 character pattern.cpp


, 1 \#include <stdio. h>
', 2
. ·, ,: · · int · main () {
-rti · 4 · char i , J. ,•
'11 ·~ for ( i = 65 ; i <= 70 ; i ++) {
·~ for ( j = 65 ; j <= i ; j ++) {
7. printf ( "%c " , j );
8
9 }
10 printf ( \n 11 11
);

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

~s < > Q7 character pattern.cpp


QS.cpp QB 2.cpp QB.cpp
1 \#include<stdio. h>
t 2 main ()

~ {
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

'lb Resources db C ompi·1e _ ✓_ Debug


_ Log @ Find-Results
- 0 Console x Close

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

It .JI,/ 1''•1<, !1/

,✓ Debug 19 Find Results ~


~ · tools AStyle' Window Help

Ill a :: © ~~c GJ .g : l TDM-GCC 9.2.0 64-bit Releas,v ~ ,...

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

~ TDM-GCC 9.2.0 64-bit Releas, v


AR
'-~C
·S
i (globals) V

i !] CJ
Classes < > power(x,n}.cpp x Q14.cpp
X

int 1 \#include<stdio. h>


2 main ()
- {
4 int n, fact =l ;
5 printf ( " Enter a number ");
6 scanf ( %d",&n); 11

for ( int i =l ; i <= n; i ++)


{
I
9 i
I 10 \ printf ( "%d \ n " , i );
, 11
12 }
tyle Window Help

r: ·B = TDM-GCC 9.2.0 64-bit Re/eas v


(globals)
V

Proiect Classes < > power(x,n}.cpp lf1


Q14.cpp
i: mt
1 ~include<stdio.h>
n: mt 2 main ()
r: mt 1 {
4 int x , n , r =l ;
X'. mt
5
printf ( "Enter the number(x) : " );
6 scanf ( "%d" ,&x)·
7
printf ( "Enter power(n) : " );
8 scanf ( ' %d &n);
1 11
,

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 }

✓ Debug Lc:J Find Results o Console x Close

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

6 scanf ( "%d" ,&d);


7
8 while ( d>0)
l1 - {
1: 10 r =d%2;
\, 11 b=b+r *pow(10, i );
II
·12 d=d/ 2;
: 13 i ++;
I 14 }
15 printf ( %d , b); 11 11

11 16 }
\I

Ii
I'
l'
1\
\'

. , .. ·1 .
r rt. Resources dll Complle Log i...,.,. Debug 19 Find Results 8
~ ,,. ... ,_ !• -

Compil ation results ~ -·


C:\U9ers\dheer\Documents\MY C CODES\Q
21 decimal to octal.cpp - Embarcadero Dev-C++ 6.3
Edit Search View Project Execute Tools
AStyle Window Help
CJ
.g i TDM-GCC 9.2.0 64-bit Releas, v 1111 aa
lu1 aa
\ (g\oba\s) V
V

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 } .

15 pri ntf ( "%d " , oct al );


16 }

• Com pile r liti Res ourc es dll Com


✓ Deb ug 19 Find Res ults 0 Console
pile Log x Clos_
e __ ___,;,i;;aiaai_

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

,15 printf( "%d '1 , d ); .


16 }

· r 'ti Resources dlJ compile Log ✓ Debug @ Find Results ~ Console x

Compilation results ..•


_ _ __ _ . •.._,~1~r.•r•t!V!'f)'IPf!!fFml?'''1~T": !''f17,'f!fl1"~ 4'--:-:"1-:';-e("' r"': r •1·••"-'~Y r-' ICIP II

~ _~--~--. ~ ;i -~ . ::. . r=1 ·8 j LTDM-GCC 9.2.0 64-bit Releas, v . i +, ,. i ,. ,.,


i' (globals) v I '!

\; Classes < rfJ CJ ii


> Q22 binary to decimal.cpp X

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 }

ces db Compile Log ✓ Debug @ Find Results ca Console x CloN


\ (globals) V

{] CJ li1
ses < > arrnstrong number.cpp X

1 #include< stdio. h>


2 main ()
- {
4 int n, rem , sum=0, cube , n1 ;
5 printf ( "Enter number : " );
6 scanf ( "%d" ,&n);
nl=n;
while ( n>0 )
{
rem=n%10 ;
11 cube =rem*rem*rem ;
12 sum=sum+cu be ;
13
14 i n=n/ 10 ;
15 }
I

16 if ( sum== nl )
{
11\
18
19
,printf ( "number is armstr~ng ''.) ; ,
'} ', "·,,''"',' '·,, ,\.1' ', ,,,,

20 else , ·,,, ,• \,. :... ,':, '

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,

' ' 1\ ' '


'1

L·\.;\
~ '' '

.' I '
' 1\ I

number u);

', I j, l I

II ;' I
' I • l
,11 ' 1•
pile Log ·. ✓ ' Debug

You might also like