0% found this document useful (0 votes)
10 views25 pages

Check

The document contains a series of programming tasks that demonstrate basic programming concepts such as displaying messages, checking conditions, and performing calculations. Each task includes a flowchart, pseudo code, algorithm, and C code implementation. The tasks cover topics like printing 'Hello World', checking if a number is positive or negative, determining even or odd numbers, converting temperatures, finding roots of quadratic equations, calculating interest, and identifying leap years.
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)
10 views25 pages

Check

The document contains a series of programming tasks that demonstrate basic programming concepts such as displaying messages, checking conditions, and performing calculations. Each task includes a flowchart, pseudo code, algorithm, and C code implementation. The tasks cover topics like printing 'Hello World', checking if a number is positive or negative, determining even or odd numbers, converting temperatures, finding roots of quadratic equations, calculating interest, and identifying leap years.
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/ 25

Question 1: Write a program to display “Hello World” on the computer screen.

Flowchart:
START

PRINT HELLO
WORLD

STOP

PSEUDO CODE:

● Begin
● Print (Hello World)
● End

ALOGORITHM:

Step 1: Start

Step 2: Print (Hello World)

Step 3: Stop

Code:

#include<stdio.h>

#include<conio.h>

int main()

printf(“Hello World”);

return 0;

}
Output:

Question 2: Write a program to check whether the entered number is positive or negative.

Flowchart:
START

READ X

YES

IF PRINT X IS
POSITIVE

NO

PRINT X IS
NEGATIVE

STOP
PSEUDO CODE:

● Begin
● Read X
● If (X>0) Then
● Print (X Is Positive)
● Else – Print(X is negative)
● End

Algorithm:

Step 1: Start

Step 2: Read a Variable X

Step 3: If X>0 print X is positive

Step 4: Else print X is negative

Step 5: Stop

Code :
#include<stdio.h>

#include<conio.h>

int main()

{ int X;

printf("Enter a number");

scanf("%d",&X);

if(X>0)

printf("The entered number is positive");

else {printf("The entered number is negative");}

return 0;

Output :
Question 3: Write a program to check whether number is even or odd.

Flowchart :
START

Read input
of number

Is number YES
divisible by
Print
2
the

NO

Print the number is


odd

STOP
Pseudo code:

● Begin
● Read number
● If number/2 =0
● Print the number is even
● Else (Print – the number is odd)
● End

Algorithm:

Step 1: Start

Step 2: Read the number to check if odd or even

Step 3: Check whether the number is divisible by 2 or not

Step 4: If divisible by 2 – Print (“the number is even”)

Step 5: Else – Print (“the number is odd”)

Step 6: Stop

Code:

#include<stdio.h>

#include<conio.h>

int main(){ int num, remainder;

printf("Enter the number you want to check whether is even or odd");

scanf("%d",&num);

remainder= num%2 ;

if(remainder==0)

printf("The number is even");

else{printf("The number is odd");}

return 0;

Output:
Question 4: write a program to convert temperature from degree Celsius to Fahrenheit.

Convert temperature from Celsius to Fahrenheit using formula

Flowchart:
Start

Read input temperature


in degree Celsius

Convert temperature from Celsius


to Fahrenheit using formula

Print the temperature in


Fahrenheit

Stop
Pseudo code:

● Begin
● Read temperature in Celsius
● Temperature in Fahrenheit = (temp in Celsius *9)/4+32
● Print the temperature in Fahrenheit
● End

Algorithm:

Step 1: Start

Step 2: Read the temperature in Celsius

Step 3: Convert temperature from Celsius to Fahrenheit using formula

Temperature in Fahrenheit = (temp in Celsius*9)/5+32

Step 4: Display temperature in Fahrenheit

Step 5: Stop

Code:

#include<stdio.h>

#include<conio.h>

int main()

{
int temp_c, temp_f;

printf("Enter the temperature in degree celcius");

scanf("%d",&temp_c);

temp_f=(temp_c*9)/5+32;

printf("The temperat degree fahrenheit is %d", temp_f);

return 0;

Output:
PIC PROJECT-5

Question 5: Write a program to find roots of quadratic equation

Flowchart:
Start

Read input values of


the coefficients

Find the value of


Discriminant (D)

YES
IS D>0 Calculate roots using
formula roots =-b+sqrt/2a

YES
IS D-0 Calculate the equal roots
using formula roots = -
b/2a

NO

Print the values of Print the values


Print the equation
equal roots of roots
has no real roots

STOP
Pseudo code:

● Begin
● Read the values of the coefficient a,b,c
● D=b2-4ac
● If (D>0) Print the distinct roots
● If (D=0) Print the equal roots
● If (D<0) Print the equation has no real roots
● End

Algorithm:

Step 1: start

Step 2: read the coefficients of quadratic equation

Step 3: calculate the value of discriminant

Step 4: If (D>0) Print the distinct roots

Step 5: If (D=0) Print the equal roots

Step 6: if (D<0) Print the equation has no real roots

Step 7: stop

Code:
#include<stdio.h>

#include<conio.h>

#include<math.h>

int main()

int a,b,c,D,r1,r2;

printf("Fill the coefficients for the quadratic equation of which you want to find roots of\n");

printf("Enter the value ofa\t");

scanf("%d",&a);

printf("Enter the value of b\t");

scanf("%d",&b);

printf("Enter the value of c\t");

scanf("%d",&c);

D=(b*b)-4*a*c;

if(D>0)
{

r1=(-b+sqrt(D))/2*a;

r2=(-b-sqrt(D))/2*a;

printf("The roots for the quadratic equation are ral and distinct\n");

printf("Root 1=%d, Root 2=%d",r1,r2);

}
else if(D==0)

r1=(-b+sqrt(D))/2*a;

r2=r1;

printf("The roots for the quadratic equation are equal\n");

printf("Root1=%d, Root 2=%d",r1,r2);

else

printf("The equation does not have any real roots for the inputed values of the coefficients");

} return 0;

Output:
Question 6: Write a program to calculate simple interest and compound interest.

Flowchart:

START

Read the input of


choice number

Read the values


p,r,t

Calculate the compound False True Calculate the simple


Is choice
interest using the interest using the
number=
formula formula

CI = p(1+r/100)*t SI = p*r*t/100

Print the
Print the value
compound value simple
interest interest

STOP
Pseudo code

• Read the choice number


• Read the values of principle(p), rate of interest(r) and time duration(t)
• If choice number is 1 print SI = p*r*t/100
• If choice number is 2 print CI = p(1+r/100)*t
• End

Algorithm:

Step 1: Start

Step 2: Read the choice number from user

Step 3: Read the values of p, r, t

Step 4: If user chooses choice number 1 print the simple interest using formula SI =p*r*t/100

Step 5: If user chooses choice number 2 print the compound interest using the formula CI =p(1+r/100)*t

Step 6: Stop

Code:

#include <stdio.h>
#include <math.h>
void main() {
printf( "enter the choice si==0 amd for ci==1");
int a;
float ci;
float si;
float p;
int t;
float r;
float d;
float b;
float am;
scanf(" %d",&a);
printf(" enter principal rate and time");
scanf("%f%f%d" ,&p,&r,&t);

if (a==0)
{si=(p*r*t)/100;
printf("%f",si);
}
else if (a==1)
{ b=(1+(r/100));
d=pow(b,t);
am=d*p;
ci=am-p;
printf("%f",ci);
}
else {printf(" invalid choice");}

}
Output:
Question 7: Write a program to check whether a year is leap or not

Flowchart:

START

Read input
year

Is the year True


divisible Print: The
by 400 entered year
is a leap year

False

Is the year
Prdin
ivti:sIib
t lies nboy t True Print: It is
not a leap
a lea1p00year
year
STOP

Pseudo code:

● Begin
● Read input year
● If Year% 400=0 print : leap year
● Elif Year%100=0 print: not leap year
● Elif Year%4=0 print: leap year
● Else print it is not a leap year
● End

Algorithm:

Step 1: Start

Step 2: Read the year from the user

Step 3: If the year is divisible by 400 print: leap year

Step 4: Else If the year is divisible by 100 print: not a leap year

Step 5: Else If the year is divisible by 4 print: leap year

Step 6: Stop

Code:

#include<stdio.h>

int main()

int year;

printf("Enter the year\t");

scanf("%d",&year);

if(year%400==0)

printf("The entered year is a leap year");

else if(year%100==0)

{printf("It is not a leap year");

}
else if(year%4==0)

printf("It is a leap year");

else{printf("It is not a leap year 0");}

return 0;

Output:
Question 8: Write a program to check whether entered character is vowel, consonant or number.

Flowchart:
Start

Read input
character(ch)

Is ch = Print: The
TRUE entered
A,e,I,o,u,A,E, character is a
I,O,U vowel

False

True
Is ch ∈ a Print: The
to z entered
character is a
consonant
False

Is ch ∈ 0 True
Print: the
to 9 entered
character is a
number
False

Print: You have


entered a special
character

STOP

Pseudo code:

● Begin
● Read input character (ch)
● If ch = a, e, i, o, u, A, E, I, O, U print(“the entered character is a vowel”)
● If ch ∈ a to z print(“the entered character is a consonant”)
● If ch ∈ 0 to 9 print(“the entered character is a number”)
● Else print(“You have entered a special character”)
● End
Algorithm:

Step 1: Start

Step 2: Read the input character (ch) from the user

Step 3: If the inputted character is among the vowels print (“The entered character is a vowel”)

Step 4: If the inputted character is among the consonants print (“The entered character is a
consonant”)

Step 5: If the inputted character is among the numbers print (“The entered character is a number”)

Step 6: Else print : You have entered a special character

Step 7: Stop

Code:

#include<stdio.h>

int main()

{ char ch;

printf("Enter a character");

scanf("%c",&ch);

if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')

printf("The entered character is a vowel");

else if((ch>='a'&&ch<='z')||(ch>'A'&&ch<='z'))

printf("The entered character is a consonant");

else if (ch>='0'&&ch<='9')

printf("The entered character is a number");

}
else printf("You have entered a special character");

return 0;

Output:
Question 9: Write a program to display size of integer, floating point and character using size of
operator.

Flowchart:
START

Print size of integer


using: sizeof(int)

Print size of
character using:
sizeof(char)

Print size of
floating point
using: sizeof(float)

STOP

Pseudo code:

● Begin
● Print (“size of integer”)
● Print (“size of char”)
● Print (“size of float”)
● End

Algorithm:

Step 1: Start

Step 2: Print the size of integer

Step 3: Print the size of character

Step 4: Print the size of float

Step 5: Stop

Code:
#include<stdio.h>

int main()

printf("Size of integer is %d\n", sizeof(int));

printf("Size of integer is %d\n", sizeof(char));

printf("Size of integer is %D\n", sizeof(float));

return 0;

Output:
Question 10: Write a program to find the maximum of 2 numbers.
Flowchart:

START
fghgh

Read input a and b

TRUE
Is a>b
a is greater

IS b>a

TRUE

IS b ==a
b is greater

STOP

Pseudo code:

• Begin
• Read value of a and b
• Ifa>b print a is maximum
• Else if b>a print b is maximum
• Else print a==b
• End
Algorithm:

• Start

• Input two numbers, a and b

• If a > b, then max = a

• Else, max = b

• Display max

• End

Code:

#include <stdio.h>

int main() {
float a,b;
printf(" enter the no");
scanf( "%f%f",&a,&b);
if (a>b)
{printf("no a is maximum");}
else if (a==b)
{printf(" both are equal");
}
else
{ printf(" b is max")
;}
}

You might also like