0% found this document useful (0 votes)
46 views

Codoo - Qqs C: Lguestion 5.b.c X HP/Documentsquestion

The document contains C code for multiple programming questions. It includes code snippets to check if a number is prime, calculate the sum of a series, check if a number is an Armstrong number, and print patterns of asterisks. The code uses basic C constructs like loops, conditional statements, functions and includes standard input/output header files.

Uploaded by

Hitesh
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)
46 views

Codoo - Qqs C: Lguestion 5.b.c X HP/Documentsquestion

The document contains C code for multiple programming questions. It includes code snippets to check if a number is prime, calculate the sum of a series, check if a number is an Armstrong number, and print patterns of asterisks. The code uses basic C constructs like loops, conditional statements, functions and includes standard input/output header files.

Uploaded by

Hitesh
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/ 7

L

CODOO|QQS C
Start here X Lguestion5.b.c X
2
#1ncAUsers\ HP\Documentsquestion 5 b.C
nt naiH7 1
3 int n, 1,
varE
printf ("Enter a positive integer: ") ;
scanf ("ad", &n)
for (i =
2: i <=n/ 2: ++i)

if (n * i =
0) (
0 var 1;
11 break;
12
L3

14
i f (n == 1)
printf("1 is neither prime nor composite. ") ;

18 eLse

19 if (var = 0)
20 is prime number. ", n);
else
printf(" *d a

printf("sd is not a prime number. ", n);


23
4
return 0:

27

Logs&others
Code:BlocksX Search results X Cccc x Rild lon X Rild meccanec x conChecAlors,.Y cCe
nChoclc0
T
int a, D, X, Y. n:
printt("Enter the value of a: ");
scanf(*d",sa);
printt ("Enter the value or bi )
scant(d", b):
printE("Enter the value Or **
scant("*
printr(nter the value or n: )
12 scant(d,an)
13 svitch (n)
14 1
case *

*\D
7
8 break
9 cAse
Ya (x**})+ (b°b)
rntE(ine value or y d\n, Y
break;
case
printr(Ine value or y din, Y
break;
Case

printr("The value of y d\n", y):


break;
default
printE(Invalid value of Ma"):
break;

return
Lnclude
main (

| int a=0,b=l,i, C, n;
printf ("enter the value of n : \n");
Scanf("%d", &n) ;
printf ("sd, ""sd, ", a,b));
10 for (i=1#ic=n-2;i++)
11
12 C atb;
13 printf("$d,", c)
14 a-b
15 b-c
16
17
18
19
D0O|aals C
tart here X question 5 b.c X *question 4a.c X question 5a.c X question 5f.c X
#1nclude <stdio.h>

int main ()

int i, j, n=3;

for (i=n: i>=1; i--)

for (j=i: j>=1; j--)


10
11
printf("*d ", j):
printf("\n");

return 0;

17

Logs& others

Code:Blocks X Search results X Cccc x Ruild loa x Ruild mecca ConChark0lorn nnf
stion S D.C question 4a.c question 5a.c question S1.C question Da.c

#include <stdio.h>

void main ()

float x, sum, no_row;


int i,n
printf ("Input the value of x :");
scanf("sf", &x)
printf("Input number of terms : ");
Scant("ad",án)
sum =I; no_row = :
for (i=l:i<n;i++)

no_row= no_row*x/ (Eloat) i;


sum =sumt no_rOW?

printf("\nThe sum i s : s f \ n " ,sum)


5a.c
stion S D. question 4a.c A
question question St.C *
question a.c
#include <stdio.h>
|int main (){
int num, originalNum, remainder, result = 0;

printf ("Enter a three-digit integer: ");


3cant ("d", &num) »
originalNum = num;

while (originalNum != 0)
// remainder contains the last digit
remainder = originalNum * 10;

result += remainder * remainder * remainder;

removing last digit from the rigLDa number


originalNum /= 10

if (result == num)

printf ("%d is an Armstrong number. ", num)


else
printf("sd is not an Armstrong number. ", num) ;

return 0:
quesuo9 ec
estion 5 D.C*
question 4a.C2 question a . c question Sf.c AquestiIon 5a.c Aqueston 5 C.C

#include <stdio.h>
int main ()
int num, 1, count = 0;

for (num=l; num< 300; numt+)

lnt prime = 1;

for (i =2; i < num; i++)

i f (num.i == 0)

Prime O;
break;

i f (prime)

prime ("%d \n", num) ;

You might also like