0% found this document useful (0 votes)
4 views10 pages

R N T T: "En Er He Number" " "

The document contains multiple C programming code snippets, each demonstrating different functionalities such as calculating factorials, generating Fibonacci sequences, finding prime numbers, and printing patterns. There are several syntax errors and formatting issues present in the code examples. Overall, the document serves as a collection of C programming exercises with varying levels of complexity.

Uploaded by

brajagir
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)
4 views10 pages

R N T T: "En Er He Number" " "

The document contains multiple C programming code snippets, each demonstrating different functionalities such as calculating factorials, generating Fibonacci sequences, finding prime numbers, and printing patterns. There are several syntax errors and formatting issues present in the code examples. Overall, the document serves as a collection of C programming exercises with varying levels of complexity.

Uploaded by

brajagir
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/ 10

1 #i nclude<stdio .

h~
2 • i nt main() {
3 int n,fact=1,i=1,sum=0,m;
4 pr i ntf( "ent er t he number" );
5 scanf( "%d " .&n);
6 m=ni;
7 whi l e(i<=n)
8· {
9 whi l e(i<=n%10)
10 • {
11 fact=fact*i;
12 i +=1;
13
14 }
15 i=1 ;
16 sum+=fact;
17 n=ni/ 10;
18 fact=1 •·
19 }
20 if (sum=m)
21 • {
22 printf( "The given number %d is a strong number" ,m);
23
24 }
25 els e
26 printf( "The given number is %d not a strong number" ,m);
27
28 r etur n 0;
29 }
1 #include <stdio .h>
2
3 • int main() {I
4 i nt n,a,b;
5 printf( "Enter the number" );
6 scanf( "%d" ,&n);
7 printf( "Enter the range\nFirstnumber:" );
8 scanf( "%d" ,&a);
9 printf( "Second number:'' );
10 scanf( "%d" ,&b);
11 fo r ( int i=a;i<=b;i++)
12 • {
13 pri ntf( "%d x %d =%d\n" ,n,i,n*i);
14 }
15 return O;
16 }I
1 II Online C compi l er to run C program online
2 #i nclude <stdio. h>
3
4•i nt main() I~
5 i nt n,i,s,j,p;
6 pr i ntf( "Enter the number of rows required" );
7 scanf( "%d" ,&n);
8 f or (i=O;i<n;i++)
g. {
10 for (s=1;s<n-i ;s++)
11 printf(" ");
12 for (j =O;j <=i;j ++)
13 • {
14 if(j ==O I I i = O)
15 p=1;
16 else
17 p=(p*(i-j +1 ))1j ;
18 printf ("%d" ,p);
19 }
20 print f( "\n ") ;
21 }
22
23
24 ret urn O;
25 }
lude<stdio.h>
main() {
int n1,n2,i,prime=O;
pr i ntf ( "Enter the f i rst number" );
scanf( "%d ",&n1);
pri ntf( "Enter t he second number'');
scant ( "%cl" •&n2) ;I
i nt m=n1;
while(n1 <=n2)
{
i nt count=O;
if(n1 >1)
{
f or (i=1;i<=n1;i++ )
{
if(n1%i ==O)
{
count=count+1 ;
}
}
if(count= 2)
{
prime=prime+1 ;
}
n1 =n1 +1 ;
}
el se
n1=n1 +1;
}
pri ntf( "The number of prime numbers between %cl and
%cl is %d ", m,n2,prime);

ret urn O;
}
1 // Online C compil er to run C program onl ine
2 #i nclude <st dio. h>
3
4• i nt main( ) {
5 int n=S, i, j;
6 f or (i=1:i<=n;i++)
7• {
8 f o r (j-1 ;j <-n-i;j ++)
9 prini:f (" ");
10 f or(j=l ;j<=( 2*i-1) ; j++)
11 print f ("*" ) ;
12 printf ( "\n");
13 }
14 f or (i=n- 1;i>=1;i-- )
15 • {
16 f or (j=1;j<=n-i;j ++)
17 print f (" ") ;
18 f or@J=1; j <=(2*i- 1); j +-i1]
19 prini::f ("*" );
20 prini:f (" \n ");
21 }
22 return O:
23 }
24
1 #include <stdio . h>
2
-
3 • int main() {I
4 int n;
5 pri ntf ("Enter the number" );
6 scanf ( "%d" , &n);
7 float sum=0. 00 ;
8
9 fo r ( f l oat i =1. 00 ;i<=n;i++)
10 · {
11 sum=sum+( 1/ i);
12 printf ("%. 2f" , 1/ i);
13 if (i<n)
14 printf("+" );
15 }
16 pri nt f ( "=%.2f" ,sum);
17 return O;
1s }I
11 un1me L comp 1.Ler r o ru n L program onJ.Lnie
1

2 #include <stdio.h>
3
,4 .. int main () {
5 int: n=4 , i j ;
I

6 for (i=1 ;i<=n;i+¼)


7., f
8 for (j =1;j <=n-i ;j ++ )
9 printf ( 11
'' ) :

10 far (j=1;j<=(2*i- 1);j ++)


11 pri ntf,( "*" );
12 printf ( ' \n·•);1

13 }
14 return o;·
15 }
16
1 / / Onl i ne C compile1- to r un C program onl ine
2 #include <stdio . h>
3
4• int main() @
5 i nt a=O,b=l ,c;
6 int n;
7 printf( "Enter the number" );
8 scanf( "%d" ,&n);
9 printf( "The fibonacci se1es are as follows: \n");
10 for ( int i =l ;i<=n ;i++)
11 • {
12 printf ( "%d\n" , a);
13 c=a+b;
14 a=b;
15 b=c ;
16 }
17
18 return O;
19 }
1 // Online C compiler t o run C program online
2 #include <stdio .h>
3
4•
.
1nt main() {i
-'
. ..
5 int a,b,gcd;
6 printf( "Ent er the first number");
7 scanf( "%d" , &a);
8 printf( ''Enter the second number ");
9 scanf( "%d " ,&b);
10 for ( int i=1;i<=a && i <=b;i++ )
11 • {
12 i f (a%i=O && b%i ==O)
13 gcd=i;
14 }
15 pri ntf( "The greatest common divisor of %d and %d is %d" ,a,b,gcd);
16
17 return O;
18 }
1 // Onl ine C co.mpi ler to run C program ionline
2 #include <stdio~h>
3
4 .. int ma1i n() i
5 int n,.bin=O,numr O;
6 p,,.. intf ( u. Enter the numbern ):
7 sc.anf ( nltd n &n') ;
If

8 whilre (n>O)
g. {
10 bin=(bin•* 10 + n'%2 );
111 n=n/ 2 ;
12 }
13 while(bin>O)
14 • {
1.5 num:: : num*1O+r C: binl 1O)i ;
16 bin=bin/ 10;
17 }
18 pr intf t( %d' num) ;
11 1
,

19 return O;
20 }

You might also like