0% found this document useful (0 votes)
15 views7 pages

Pps Assignment (21cse38)

The document contains a series of C programming assignments by Rohit Kumar, a student in the CSE branch. It includes solutions for checking if a character is a vowel or consonant, finding the largest of three numbers, determining if a number is positive or negative, checking if a string is a palindrome, and calculating the sum of natural numbers. Each solution is accompanied by code snippets and prompts for user input.

Uploaded by

rohitsah9771
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)
15 views7 pages

Pps Assignment (21cse38)

The document contains a series of C programming assignments by Rohit Kumar, a student in the CSE branch. It includes solutions for checking if a character is a vowel or consonant, finding the largest of three numbers, determining if a number is positive or negative, checking if a string is a palindrome, and calculating the sum of natural numbers. Each solution is accompanied by code snippets and prompts for user input.

Uploaded by

rohitsah9771
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

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:-
Q2.Write 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:-
Q3.Write 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:-

Q5.Write 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:-

You might also like