Check
Check
Flowchart:
START
PRINT HELLO
WORLD
STOP
PSEUDO CODE:
● Begin
● Print (Hello World)
● End
ALOGORITHM:
Step 1: Start
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 5: Stop
Code :
#include<stdio.h>
#include<conio.h>
int main()
{ int X;
printf("Enter a number");
scanf("%d",&X);
if(X>0)
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
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 6: Stop
Code:
#include<stdio.h>
#include<conio.h>
scanf("%d",&num);
remainder= num%2 ;
if(remainder==0)
return 0;
Output:
Question 4: write a program to convert temperature from degree Celsius to Fahrenheit.
Flowchart:
Start
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 5: Stop
Code:
#include<stdio.h>
#include<conio.h>
int main()
{
int temp_c, temp_f;
scanf("%d",&temp_c);
temp_f=(temp_c*9)/5+32;
return 0;
Output:
PIC PROJECT-5
Flowchart:
Start
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
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 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");
scanf("%d",&a);
scanf("%d",&b);
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");
}
else if(D==0)
r1=(-b+sqrt(D))/2*a;
r2=r1;
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
CI = p(1+r/100)*t SI = p*r*t/100
Print the
Print the value
compound value simple
interest interest
STOP
Pseudo code
Algorithm:
Step 1: Start
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
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 4: Else If the year is divisible by 100 print: not a leap year
Step 6: Stop
Code:
#include<stdio.h>
int main()
int year;
scanf("%d",&year);
if(year%400==0)
else if(year%100==0)
}
else if(year%4==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
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 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 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')
else if((ch>='a'&&ch<='z')||(ch>'A'&&ch<='z'))
else if (ch>='0'&&ch<='9')
}
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
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 5: Stop
Code:
#include<stdio.h>
int main()
return 0;
Output:
Question 10: Write a program to find the maximum of 2 numbers.
Flowchart:
START
fghgh
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
• 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")
;}
}