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

Chandigarh University: Assignment 1 Subject:-Computer Programing Subject:-UCT-144 Submitted To: - Ms. Anupam Mittal

The document contains computer programming assignments submitted by Sunil Kumar. It includes programs to check if a number is positive or negative, display a number pattern in a right angle triangle, find the factorial of a number, find prime numbers between 1 to 100 using a flowchart, and an algorithm to calculate the sum and average of two user-entered numbers. Solutions for each question are provided in the form of C code programs and algorithms with steps.

Uploaded by

caxak
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)
54 views

Chandigarh University: Assignment 1 Subject:-Computer Programing Subject:-UCT-144 Submitted To: - Ms. Anupam Mittal

The document contains computer programming assignments submitted by Sunil Kumar. It includes programs to check if a number is positive or negative, display a number pattern in a right angle triangle, find the factorial of a number, find prime numbers between 1 to 100 using a flowchart, and an algorithm to calculate the sum and average of two user-entered numbers. Solutions for each question are provided in the form of C code programs and algorithms with steps.

Uploaded by

caxak
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

Chandigarh University

Assignment 1
Subject:- Computer programing
Subject:-UCT-144
Submitted to:- Ms. Anupam Mittal
Submitted by:-Sunil Kumar
UID:-19BEM1001
Section A
Q1 Creat a c program to check whether a given number is
positive or negative?
Ans #include<stdio.h>
Void main ()
{
Int a;
printf(“enter a number:\n”);
scanf(“%d”,&a);
if(a>0)
{
printf(“positive”);
}
else
{
Printf(“negative”)
}
}
Q2 Create a program to display the patten like right angle
triangle with a number which will repeate a number a
row?
Ans #include<stdio.h>
Int main()
{
Int a,i,j;
printf(“enter a number to be repeated in patten:\”);
scanf(“%d”,&a);
printf(“\n\n”);
for(j=0; j<=1;j++
{
printf(“%d”,a);
}
printf(“\n”);
}
printf(“\n”);
printf(“\n”);
for(j=0;j<=i-1;j++)
{
printf(“ ”)
}
for(j=2;j>=1;j--)
{
printf(“%d”,a);
}
printf(“\n”);
}
return 0;
}
Q3 Create a program to find the factorial value of a
number.Also write the algorithim and draw a flowchart.
Ans #include<stdio.h>
Int main()
{
Int I,num;
printf (“enter a number;\n”);
scanf(“%d”,&num);
printf(“factors of number are:”);
print(“\n\n1\n”);
for(j=1;j<=num;j++)
{
If(num%j==0)
{
printf(“%d\n”,i);
}
}
return 0;
}
ALGORITHM
1. START
2. Enter a number “num”
3. Print “1”
4. For (j=2;j<=num;j++)
5. If(num%i==0)
6. Print “1”
7. End
Q4 Develop a flowchart to find the prime number
between 1 to 100 ?
Ans
START

INITIALISE
i,j,t

no
i=2 i++
end
I<=1
print
(“%d”,i)
yes
t=0

yes

j=2 j++
break no If(t== no
j<=i/2
0)

yes

If(i%j= no
t=1;
=0)
Q5 Devolop an algorithm ( a step by step process) for a
program to calculate the sum and average of two
numbers entered by the user of the programe.
Ans ALGORITHIM
1. START
2. ENTER TWO NUMBERS X AND Y
3. SUM=X+Y
4. MULTIPLICATION=X*Y
5. PRINT “SUM”
6. PRINT “MUTIPLICATION”
7. END

You might also like