[go: up one dir, main page]

0% found this document useful (0 votes)
20 views4 pages

Cycle 3

The document contains a list of 28 programming problems for students to solve related to basic C programming concepts like data types, conditional statements, loops, functions, arrays, matrices, searching and sorting. The problems cover topics such as checking if a character is a vowel, calculating grade based on marks, finding sum and average of positive numbers, developing a basic calculator, checking prime numbers, reversing and checking palindrome of numbers, converting between decimal and binary numbers, calculating factorial, greatest common divisor, Fibonacci series, checking Armstrong and Adam numbers, generating perfect numbers in a range, calculating trigonometric series, searching and sorting arrays, finding largest difference between two elements in an array, inserting and deleting elements, matrix multiplication and properties of matrices.
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)
20 views4 pages

Cycle 3

The document contains a list of 28 programming problems for students to solve related to basic C programming concepts like data types, conditional statements, loops, functions, arrays, matrices, searching and sorting. The problems cover topics such as checking if a character is a vowel, calculating grade based on marks, finding sum and average of positive numbers, developing a basic calculator, checking prime numbers, reversing and checking palindrome of numbers, converting between decimal and binary numbers, calculating factorial, greatest common divisor, Fibonacci series, checking Armstrong and Adam numbers, generating perfect numbers in a range, calculating trigonometric series, searching and sorting arrays, finding largest difference between two elements in an array, inserting and deleting elements, matrix multiplication and properties of matrices.
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/ 4

Computer Programming Lab

Record Programs for Cycle -3

1. Write a C program to check whether the given character is vowel or not using switch case
2. Write a C program to print the grade of student based on the 6 subjects marks using switch
case.
3. Write a C program to find the sum and average of +ve numbers using goto statement.
4. Write a menu driven program to perform simple calculator.
5. Write a C program to find whether the given number is prime or not using break statement.
6. Write a C program to find the square root of ‘n’ positive numbers using continue statement
7. Write a C program to print the multiples of given number below 50 using continue statement
8. Write a C program to find the reverse of a given number

#include <stdio.h>

int main() {

int n, reverse = 0, remainder;

printf("Enter an integer: ");


scanf("%d", &n);

while (n != 0) {
remainder = n % 10;
reverse = reverse * 10 + remainder;
n /= 10;
}

printf("Reversed number = %d", reverse);

return 0;
}
9. Write a C program to check whether the given number is palindrome or not.
#include <stdio.h>

int main() {

int n, n1, reverse = 0, remainder;

printf("Enter an integer: ");


scanf("%d", &n);
n1 = n;
while (n != 0) {
remainder = n % 10;
reverse = reverse * 10 + remainder;
n /= 10;
}

printf("Reversed number = %d", reverse);


if(n1 == reverse)
printf("\n %d is a number palindrome", n1 );
else
printf("\n %d is not a number palindrome", n1);

return 0;
}
10. Write a C program to convert given decimal number to binary number.
/* Program to convert decimal number to binary */
#include<stdio.h>

int main(){
int a[10],n,i;

printf("Enter the number to convert: ");


scanf("%d",&n);
for(i=0;n>0;i++)
{
a[i]=n%2;
n=n/2;
}
printf("\nBinary of Given Number is=");
for(i=i-1;i>=0;i--)
{
printf("%d",a[i]);
}
return 0;
}

11. Write a C program to convert given binary number to decimal number.

#include <stdio.h>
#include <conio.h>
int main()
{
// declaration of variables
int num, binary_num, decimal_num = 0, base = 1, rem;
printf (" Enter a binary number with the combination of 0s and 1s \n");
scanf (" %d", &num); // accept the binary number (0s and 1s)

binary_num = num; // assign the binary number to the binary_num variable

while ( num > 0)


{
rem = num % 10; /* divide the binary number by 10 and store the remainder in
rem variable. */
decimal_num = decimal_num + rem * base;
num = num / 10; // divide the number with quotient
base = base * 2;
}

printf ( " The binary number is %d \t", binary_num); // print the binary number
printf (" \n The decimal number is %d \t", decimal_num); // print the decimal
getch();
}

12. Write a C program to find the factorial of a given number.


13. Write a C program to find the GCD of given numbers.
#include <stdio.h>
int main()
{
int n1, n2, i, gcd;

printf("Enter two integers: ");


scanf("%d %d", &n1, &n2);

for(i=1; i <= n1 && i <= n2; ++i)


{
// Checks if i is factor of both integers
if(n1%i==0 && n2%i==0)
gcd = i;
}

printf("G.C.D of %d and %d is %d", n1, n2, gcd);


return 0;
}

14. Write a C program to generate the Fibonacci series upto ‘n’ terms.
15. Write a C program to check whether the given number is armstrong or not
16. Write a C program to check whether the given number is adam number or not
Adam number is a special type of number in which the square of the number is the
reverse of the square of the reverse of the number. In other words, if we take the square
of a number and the square of its reverse, the two results should be the same after
reversing the order of the digits.
For example, 12 is an Adam number because
square(12) = 144
square of its reverse (21) is 441,
which is the reverse of 144.

17. Write a C program to generate perfect numbers within a given range


18. Write a C program to generate sin(x) series upto n terms (convert degrees into radians)
(1 – x2/2! + x4/4! –x6/6!+…)
19. Write a C program to generate cos(x) series upto n terms (convert degrees into radians)
(x – x3/3! + x5/5! –x7/7!+…)
20. Write a C program to search an element in the given array (linear search)
21. Write a C program to sort the given array
22. Write a C program to find two elements in an array such that difference between them is
largest.
23. Write a C program to insert an element in an array at a given index.
24. Write a C program to delete an element in an array
25. Write a C program to find the multiplication of two matrices
26. Write a C program to check whether the given matrix is symmetric matrix or not
27. Write a C program to check whether the given matrix is unit matrix or not
28. Write a C program to find the transpose of a matrix

You might also like