ASSIGNMENT
NAME-ROHIT KUMAR
ROLL NO-21cse38
BRANCH-CSE
SUBJECT-PPS
Q1. Write a C Program to Check Whether a Character is a Vowel or Consonant.
Sol:- #include<stdio.h>
#include<conio.h>
int main()
char ch;
printf("Enter an alphabet:");
scanf("%c", &ch);
printf("You have entered %c\n",ch);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'|| ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
printf("%c is Vowel.",ch);
else
printf("%c is Consonant.",ch);
return 0;
Output:-
[Link] a C program to find the largest number among three numbers?
Sol:- #include <stdio.h>
int main()
int a, b, c;
printf("Enter the three
numbers putting spaces
between each number\n");
scanf("%d%d%d", &a, &b,
&c);
printf("You have entered
%d, %d and %d
consecutively.\n", a, b, c);
if (a > b)
if (a > c)
printf("The Largest
Number Is %d", a);
}
else
printf("The Largest
Number Is %d", c);
else
if (b > c)
printf("The Largest
Number Is %d", b);
else
printf("The Largest
Number Is %d", c);
return 0;
Output:-
[Link] a C program to check whether a number is positive or negative?
Sol:- #include <stdio.h>
int main()
int a;
printf("Enter an integer:");
scanf("%d",&a);
printf("You have entered
%d\n",a);
if (a>0)
printf("%d is a positive
integer.",a);
else
printf("%d is a negative
integer.",a);
return 0;
Output:-
Q4. Write a program to check whether a string is a palindrome or not?
Sol:- #include <stdio.h>
#include <string.h>
int main()
int l, i, n = 0;
char ch[100];
printf("Enter the string
either in capitals or small
case: ");
scanf("%s", &ch);
l = strlen(ch);
for (i = 0; i < l / 2; i++)
if (ch[i] == ch[l - i - 1])
n++;
// When the condition
under 'if' will be true, 'n'
will exceed.
if (n == i)
{
printf("%s is
palindrome.", ch);
else
printf("%s is not
palindrome.", ch);
return 0;
Output:-
[Link] a program to calcalute sum of natural numbers?
Sol:- #include <stdio.h>
int main()
int n, sum;
printf("Enter the last
number: ");
scanf("%d", &n);
sum = (n*(n + 1)) / 2;
printf("%d", sum);
return 0;
0utput:-