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

23ec3038 Lab6

The document contains 4 C programs: 1) to reverse the digits of a number, 2) to print the Fibonacci series up to a given number of terms, 3) to calculate the sum of the digits of a number, 4) to calculate the product of the digits of a number.

Uploaded by

23ec3038
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)
25 views4 pages

23ec3038 Lab6

The document contains 4 C programs: 1) to reverse the digits of a number, 2) to print the Fibonacci series up to a given number of terms, 3) to calculate the sum of the digits of a number, 4) to calculate the product of the digits of a number.

Uploaded by

23ec3038
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

Q.1 WRITE A PROGRAM TO PRINT THE REVERSE ORDER OF NUMBERS.

#include <stdio.h>

int main() {

int num;

int last;

int reverse;

printf("enter the number :");

scanf("%d",&num);

while(num!=0){

last=num%10;

reverse=reverse*10+last;

num=num/10;}

printf("reverse number is :%d",reverse);

return 0;

}
Q.2 Write a program for fabonacci series starting from zero.

#include <stdio.h>

int main() {

int n, first = 0, second = 1, next;

printf("Enter the number of terms: ");

scanf("%d", &n);

printf("Fibonacci Series: ");

for (int i = 0; i < n; i++) {

printf("%d, ", first);

next = first + second;

first = second;

second = next;

return 0;

}
Q.3 Write a program to print the sum of the number .

#include <stdio.h>

int main() {

int num, remainder, sum = 0;

printf("Enter a number: ");

scanf("%d", &num);

while (num != 0) {

remainder = num % 10;

sum += remainder;

num = num / 10;

printf("Sum of digits: %d\n", sum);

return 0;

}
Q.4.Write a program to print the product of the numbers.

#include <stdio.h>

int main() {

int num, remainder, product = 1;

printf("Enter a number: ");

scanf("%d", &num);

while (num != 0) {

remainder = num % 10;

product *= remainder;

num = num / 10;

printf("Product of digits: %d\n", product);

return 0;

You might also like