PF Part2 Rec
PF Part2 Rec
AIM:
To write a program to find the given number is positive or negative.
ALGORITHM:
Step 1:Start the program.
PROGRAM:
#include <stdio.h>
int main() {
int num;
printf("Enter an integer:");
scanf("%d", &num);
if (num > 0)
else
return 0;
}
OUTPUT:
Enter an interger:7
RESULT:
Thus he C Program to find the given number is positive or negative as completed and the
output was verified.
Ex.No:4c LEAP YEAR OR NOT
Date:
AIM:
To write c program to find the whether the givenear is leap year or not.
ALGORITHM:
STEP 1: Start the program.
Step 5: If true print leap year else print not a leap year.
Program:
#include <stdio.h>
int main() {
int year;
scanf("%d", &year);
if(year%400==0)
else
return 0;
}
OUTPUT:
Enter the year:2009
RESULT:
Thus the c program to find whether the given year is leap year or not was completed and
the output was verified.
Ex.No:4d GRADING SYSTEM
Date:
AIM:
To write c program to find the grade of obtained marks.
ALGORITHM:
PROGRAM:
#include<stdio.h>
int main(){
int score;
scanf("%d", &score);
switch( score / 10 ){
case 10 :
case 9 :
break;
case 8 :
/* Marks between 80-89 */
break;
case 7 :
break;
case 6 :
break;
case 5 :
break;
case 4 :
break;
default :
return 0;
}
OUTPUT:
Enter score ( 0-100 ): 75
RESULT:
Thus the C program to find the grade of obtained marks was completed and the output is
verified.
Ex.No:4c ARITHMETIC OPERATION
Date:
AIM:
To write c program to do arithmetic operation(+,-,*,/) using switch case.
ALGORITHM:
Step 1: Start the program.
PROGRAM:
#include <stdio.h>
int main() {
int a, b;
int c;
printf("1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n");
scanf("%d" ,&c);
switch(c)
case 1 :
break;
case 2 :
break;
case 3 :
break;
case 4 :
break;
default :
break;
return 0;
OUTPUT:
1.Addition
2.Subtraction
3.Multiplication
4.Division
Multiplication of 2 and 4 is : 8
RESULT:
Thus the C program to do arithmetic(+,-,*,/ ) using switch cases was completed and the
output was verified.
AIM:
To write the c program to check the character is vowel or consonants using switch case.
ALGORITHM:
Step 1: Start the program.
PROGRAM:
#include <stdio.h>
int main(){
char ch;
Case 'a':
printf("Vowel.");break;
case 'e':
printf("Vowel.");break;
case 'i':
printf("Vowel.");break;
case 'o':
printf("Vowel.");break;
case 'u':
printf("Vowel");break;
case 'A':
printf("Vowel.");break;
case 'E':
printf("Vowel.");break;
case 'I':
printf("Vowel.");break;
case 'O':
printf("Vowel.");break;
case 'U':
printf("Vowel.");break;
default:
printf("Consonant.");
return 0;
OUTPUT:
Enter any alphabet :W
Consonant.
RESULT:
Thus the C program to check the character is vowel or consonants was completed and the
output was verified.
AIM:
To write C program to find the given number is prime or not using loop,
ALGORITHM:
Step 1: Start the program.
PROGRAM:
#include <stdio.h>
int main() {
int n, i, count = 0;
printf("Enter number:");
scanf("%d", &n);
{
// check for non prime number
if(n%i==0)
count=1;}
if (count==0)
else
return 0;
OUTPUT:
Enter number:13
13 is a prime number.
RESULT:
Thus the C program to check the whether it is prime or not was completed using loop and the
output was verified.