You are on page 1of 24

File ait Search Run Compi leDebug Project Uptions Window Hclp

NONAME00.CPP =
-1-1¢]
#inc lude <stdio.h>
inc lude<conio.h>
ain)

int p,q:
f loat amount:
clrscr()
pr intf ( eitre quETtUsn nnter prlre );
Scanf ( q,&p)
amount Fp*[:

if (q>1000)
amount =0.9% amount:
printf( oamount)
else
amount) ;
printf
getchO;

FI Help B:9
cOMDL E DII
OPEN Alt-F8 Next Msg Alt-F? Prev isg Alt-F9 Comp
RuN i l e 9 Make KEYBOARD
F10 Menu
enter quntity
enter price
1100
10
9900

OPEN COMPILE RUN KEYBOARD


File adit Search Run Compile Dcbug Pro ject Uptions Window Hclp
NONAME00.CPP =
-1-[¢1
#inc lude <stdio.h>
tincludeKconio.h>
ma inD
int year
:lrscr():|
printf(
scanf ( &year)
if Cyearz100==0 &&yearz100==0)

pr intfUuny
else if(yearz1-=0 && yearu100!=0)

printfhfs Lirai Jrap urar ):


else
printfIhE yean is hat esi geae );
yetch )
dPEN b:10
FI Help Alt-P8 Next Msg
cOMPILE
Alt-r? Freu s g
RUN
Alt-F9 Comp ile F Make
KEYBOARD
F10 Menu
Enter year
1960
this year is mot leap year

OPEN cOMPILE RUN KEYBOARD


Pile dit Search Run Compi le Dcbug Projcct Uptions Window1 Hclp
NONAME0.CPP- 1-1*h
inc ludeKconio.h>
oid main()

float xl,x2,K3,yl.y2 y3,slop1 ,slop2;


Elrscr(O:

printf (
printf (
iD:scanf
scanf ,&x1)
ëx2):
printf ( );scanf ( ,&x3);
pr intf scanf ,&y1):
pr intr t
pr intf (
);scanf t ,Ry2);
);scanf &y3)
if( (y2 y1)/(x2 x1)== (y3 -y2)/(x3
-

x2))

else
printf b uheer t m etear
etch );
OPEN 12:15 cOMDLE
P1 Help AltF8 Next Msg Alt-1? Frev s g
RUN
Alt-P9 Compile F9 ake
KEYBOARD
F10 Meu
x1 :

x2 = 2

x3 = 3

yl = 1

Z
y3 = 3

All three point are


linear

OPEN cOMPILE RUN KEYBOARD


Filc 2dit Search Run Compi le Debug Pro.ject Uptions
NONAMEOO.CPP
Window Help
-1-1¢]
Hinc lude<conio.h
oid main()

int ycar
EIrscrO:
printfCEnter value of year");
scanf ("d",&year );
(yearz1-=0 && year100 = 0)?
printf (ycar i ar"):
(year 100 ==
0
R year400 ==0)?
printfyear is leap year :
printf year 1s ot leap year ) :
getchO

OPEN 15:7 cOMDII E D RUN KEYBOARD


FI Help Alt-F8 Next M'sg Alt-f? Prey sg Alt-F9 Comp i le F9 Make F10 Menu
ter value of year
280
Jear ls not leap year_
TurboCdroid

Enter value of year


B000
year ls lcap year
x Online C Compiler
programiz.com

rogramiz Learn Python


COnline Compiler

main.c Output
1 #include <stdio.h>
2 void main(){
3 int ram, shyam, ajay;
4 printf("Enter age of ram "); scanf
("%d", &ram);
printf("Enter age of shyam: "); scanf
("%d", &shyam);
printf("Enter age of ajay "); Scanf
"%d", &ajay):
switch (ram<shyam)
8
9 case 1:
10 switch (ram<ajay)
11
12 case 1:
13 printf("Ram is youngest");
14 break;
15 case 0:
16 printf("Ajay is youngest " )
17 break;
18
19
20
Switch (shyam<ajay)
21 case 0:
22 switch (shyamsajay)
23
24 case 1:
25 printf(" shyam is youn
Run
26 break;

O
19
20 switch (shyam<ajay) {
21 case 0:
22 switch (shyamsajay)
23
24 case 1:
25 printf(" shyam is youngest") :
26 break;
27 case 0:
28 printf(" ajay is youngest") ;
29 break;
30
31 break;
32
33 Run
34

O
X Online C Compiler
programiz.com

E Frogramiz Learn Python


COnline Compiler

main.c Output

/tmp/rKT8ImUotX. o
Enter age of ram : 3
Enter age of shyam 7
Enter age of ajay: 19
Ram is youngest

12 3 4 5 6 7 8 9 0

q We r t y uioo P

a sd f gh kI

T ZZX C vb n m

#1 Eng (US). Eng(HI)

O
x Online C Compiler
programiz.com
rogramiz Learn Python
COnline Compiler

main.c Output
1 #include <stdio.h>
2 main(
int n,i=1,sum=0;
4 printf"Enter valueof n");

scanf("%d",&n);
6 loop:
if(i<=n)
8 sum Sum (i*i);
=

9 i+
10 goto loop;
11
12 printf("The result is = %d " ,sum) ;

13

Run

O
LTE T

x Online C Compiler
programiz.com
Programiz Learn Python
COnline Compiler

main.c Output
tmp/Tcs0hn6R1j .o
Enter valueof n
3
The result i s = 14
x Online C Compiler
programiz.com
frogramiz Learn Python
COnline Compiler
main.c Output
1 #include<stdio.h>
2 #include<math.h>
3 int main()
4-
5 int n,r,d,sum=0,digit=0;
6 printf("Enter the value of n:");
7 scanf("%d\n" , &n);
8 if(n>0)
9
10 r=n%10;
11 n=n/10;
12 digit+*;
13
14 printf("Total digit is = %d",digit)

15 while(n>0)
16
17 r n%10;
18 n=n/10;
19 Sum sum pow(r,digit);
20
21 printf("sum=%d\n", sum):{
22 if(sum==d)
23
24 printf("the number is an
astronomic number");
25
26 else
27
Run
28 printf("the number is not
26 else
27
28 printf("the number is not
astronomic number");
29
30
Run
31

O
9:14 lil

X Online C Compiler
programiz.com

Erogramiz Learn Python


COnline Compiler

main.c Output

1 #include <stdio.h>
2 int main() {
int choice,i,n,rem,fact, flag, sum=0;
printf("press 1 for cheak given
number is prime or not\n");
5 printf("press 2 for cheak given
number is perfect or not\n");
6 printf("press 3 to find a given
number factorial \n"):
printf"press 4 for exit\n\n");
printf("Enter your choice ");
9 scanf("%d" , &choice);
10 switch(choice ){
11 case 1:
12 printf("Enter value of n")
13 for(i=2;i<=n/2;+*i)
14
15 if(n%i==0)
16
17 flag=1;
18
19 else
20
21 if(flag==0){
22 printf("%d is prime ",n)
23
24 else
25
Run
26 printf("%d is not prime".

O
9:14 TE ll.ill

X Online C Compiler
programiz.com
frogramiz Learn Python
COnline Compiler

main.c Output

23
24 else
25
26 printf("%d is not prime",n);
27
28
29 break;
30 case 2:
31 printf("Enter value of n");
32 for(i-1;i<=(n-1);i++)
33
34 rem=n%i;
35 if(rem==0){
36 sum= sum + i;
37
38 if(sum==n)
39
40 printf("%d number is perfect number"
,n);
41
42 else
43
44 printf("%d is not perfect number" ,n);
45
46
47 break;
48 case 3:
49 printf("Enter value of n"): Run
50 for(fact=1;n>0;n--)
O
9:14 l.ll

x Online C Compiler
programiz.com

Programiz Learn Python


COnline Compiler

main.c Output
- -

32 for(i=1;i<=(n-1);i++)
33
34 rem=n%i;
35 if(rem==0){
36 sum = Sum + i

37
38 if(sum==n)
39
40 printf("%d number is perfect number
,n);
41
42 else
43
44 printf(%d is not perfect number",n);
45
46
47 break;
48 case 3:
49 printf("Enter value of n")
50 for(fact=1;n>0;n--)
51
52 fact fact*n;
53 printf" factorial is = %d",fact);

54
55 break:
56
57
58 Run
59

O
9:28

X Online C Compiler
programiz.com
Programiz Learn Python
COnline Compiler

main.c Output

1 #include<stdio.h>
2
3 int main()
4
5 int stick = 21,person,computer;

while(1)
8
9 printf"Number of Match sticks
left =%d\n",stick);
10 printf("Pick 1 or 2 or 3 or 4
matches");
11 scanf("%d", &person);
12
13 if(person 4 || person< 1)
14 continue;
15
16 stick = stick
person
17
18 printf("Number of matches left =

%d\n",stick);
19
20 Computer = 5 - person

21
22 printf("out of which computer
picked up %d\n", computer);
23
24 stick =stick -

computer Run
25

O
9:29 ll.ll

X Online C Compiler
programiz.com
Efrogramiz Learn Python
COnline Compiler

main.c Output
* -- --

11 scanf('"%d", &person);
12
13 if(person 4 || person< 1)
14 continue;
15
16 stick = stick
person;
17
18 printf("Number of matches left
%d\n", stick);
19
20 computer = 5 person
21
22 printf("out of which computer
picked up %d\n", computer) ;
23
24 stick =stick computer
25
26 i f ( s t i c k == 1)

27
28 printf("\nNumber of matches
left %d", stick )
29 printf("\nYou lost the
Game \n" ):
30 break;
31
32
33
34 return 0; Run
35

O
9:28

x Online C Compiler
programiz.com

E Programiz
Learn Python
COnline Compiler

main.c Output

/tmp/aDcSAXIWS9.o
Number of Match sticks left 21
Pick 1 or 2 or 3 or 4 matches
3
Number of matches l e f t = 18

out of which computer picked up 2


Number of Match sticks l e f t = 16

Pick 1 or 2 or 3 or 4 matches
4
Number of matches l e f t = 12

out of which computer picked up 1


Number of Match sticks left = 11
Pick 1 or 2 or 3 or 4 matches
2
Number of matches l e f t = 9

out of which computer picked up 3


Number of Match sticks l e f t = 6

Pick 1 or 2 or 3 or 4 matches
4
Number of matches l e f t = 2

out of which computer picked up 1

Number of matches l e f t = 1

You lost the Game

O
x Online C Compiler
programiz.com

Programiz Learn Python


COnline Compiler

main.c Output
1 #include<stdio.h>
2 int main()
3-4
4 int i ,swap-0,n,j
5 printf("enter the value of n:\n");
scanf("%d",&n);
7 int list [n]:
printf("enter the list of n:\n");
9 for(i=0;i<n;i++)
10
11 scanf("%d",&list [i);
12
13 for(i=0;i<n;i+*)
14
15 for(j-0;j<(n-1):j++)
16
17 if(list[j1>list[j+1]){
18 Swap-list [jl:
19 list[j]-list[j+1]:
20 list[j+1]=swap;
21
22
23
24 for(i=0;i<n; i++)
25
26 printf("_ _in"):
27 printf("%d \n",list[i]):
28
Run
29

O
X Online C Compiler
programiz.com
Programiz Learn Python
COnline Compiler

main.c Output

/ tmp/22yPACSPGt.o
enter the value of n:
4
enter the list of n:
90
23
56
54

23

54

56

90

You might also like