0% found this document useful (0 votes)
38 views

C Prog

The document contains code for two programs - one to reverse a given number in C, and another to print the Fibonacci series up to a given limit in C. The number reversing program takes a number as input, initializes variables to store the reverse and perform modulo/division operations to extract digits and build the reverse. The Fibonacci program initializes variables to store the first two numbers, takes the limit as input, and uses a while loop to iteratively calculate and print each number by adding the previous two numbers.

Uploaded by

rajaroyalsk
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

C Prog

The document contains code for two programs - one to reverse a given number in C, and another to print the Fibonacci series up to a given limit in C. The number reversing program takes a number as input, initializes variables to store the reverse and perform modulo/division operations to extract digits and build the reverse. The Fibonacci program initializes variables to store the first two numbers, takes the limit as input, and uses a while loop to iteratively calculate and print each number by adding the previous two numbers.

Uploaded by

rajaroyalsk
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Program to reverse ANY given number in C

#include <stdio.h> 
main() 

int num,mod,rev=0; 
printf("Enter a number:"); 
scanf("%d", &num);
while(num>0) 

mod=num%10; 
rev=(rev*10)+mod; 
num=num/10; 

printf("Reverse of the given number: %d", rev); 
getchar(); 
}

Fibonacci series

void main() 

int i=1,o=0,c=1,n,s; 
clrscr(); 
printf("Enter the Limit\n\n"); 
scanf("%d",&n); 
while(i<=n) 

s=o+c; 
o=c; 
c=s; 
i++; 
printf("\n%d",s); 

getch(); 
}

class:

class is user defined data type that contains or hold both data and member function.it is
the collection of different data types
Object:

Object is an instance of a class that is used to access the methods and variables of the
class.

Enumerator:

Enumeration is a value data type, which means that enumeration contains its own values
and cannot inherit or pass inheritance. Enumerator allows you to assign symbolic names
or integral constants.

Simplest way to identify things,

enum DaysOfWeek
{Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday}
Struct vs class:

Structure: Initially (in C) a structure was used to bundle different type of data types
together to<br>perform a particular functionality. But C++ extended the structure to
contain functions also. The<br>major difference is that all declarations inside a structure
are by default public.<br><br>Class: Class is a successor of Structure. By default all the
members inside the class are private
Encapsulation is a technique used for hiding the propertiesand behaviors of an object and
allowing outside access only as appropriate. It prevents other objects from directly
altering or accessing the properties or methods of the encapsulated object.
Wrapping up a data and function together in a singal unit is called encapsulation
Abstraction refers to the act of representing essential features without including the
background details or explanations.

You might also like