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

Computer Programming Assignment

The document contains programming assignments completed by a student named Deepit Chikersal, including code and outputs for four different tasks: checking if a number is a palindrome, finding the largest of three numbers, calculating the sum of a series, and finding the largest number in an array. Each task includes the C code implementation and the expected output. The document concludes with a thank you note.

Uploaded by

deepit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views7 pages

Computer Programming Assignment

The document contains programming assignments completed by a student named Deepit Chikersal, including code and outputs for four different tasks: checking if a number is a palindrome, finding the largest of three numbers, calculating the sum of a series, and finding the largest number in an array. Each task includes the C code implementation and the expected output. The document concludes with a thank you note.

Uploaded by

deepit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Computer

Programming
Assignment

Student Name : Deepit


Chikersal
UID Number : O22BCA11083
Q1. Program to Check whether
number is Palindrome or not.
Answer:
Code:
#include<stdio.h>
int main()
{
int n, rev= 0, rem, ori;
printf("Enter an integer: ");
scanf_s("%d", &n);
ori = n;
while (n != 0)
{
rem = n % 10;
rev = rev * 10 + rem;
n /= 10;
}
if (ori == rev)
{
printf("%d is a palindrome.", ori);
}
else
printf("%d is not a palindrome.", ori);
}

Output
Q2. Program to find the largest
of three numbers
Answer:
Code:
#include <stdio.h>
int main() {
int a[10];
int i;
int greatest;
printf("Enter ten values:");
for (i = 0; i < 10; i++) {
scanf_s("%d", &a[i]);
}
greatest = a[0];
for (i = 0; i < 10; i++) {
if (a[i] > greatest) {
greatest = a[i];
}
}
printf("Greatest of ten numbers is % d", greatest);
return 0;
}

Output
Q3. Program to find out the sum
ofseries 1 + 2 + …. + n.
Answer:
Code:
#include<stdio.h>
int main()
{
int n, i;
int sum = 0;
printf("Enter a number upto which you want total:
");
scanf_s("%d", &n);
sum = (n * (n + 1)) / 2;
printf("\nSum of the series: ");
for (i = 1; i <= n; i++)
{
if (i != n)
printf("%d + ", i);
else
printf("%d = %d \n", i, sum);
}
return 0;
}
Output
Q4. Program to Find the Largest
Number in an Array.
Answer:
Code:
#include <stdio.h>
int main()
{
int a[10];
int i;
int greatest;
printf("Enter ten values:");
for (i = 0; i < 10; i++) {
scanf_s("%d", &a[i]);
}
greatest = a[0];
for (i = 0; i < 10; i++) {
if (a[i] > greatest) {
greatest = a[i];
}
}
printf("Greatest of ten numbers is % d", greatest);
return 0;
}

Output
THAN
K
YOU

You might also like