100% found this document useful (1 vote)
94 views

Write A Program For:: #Include

The document contains C code implementations for several common programming problems: 1) Palindrome checking for strings and numbers. 2) String reversal. 3) Sum and average of numbers. 4) Prime number checking. 5) Armstrong number checking. 6) Fibonacci series using iterative and recursive approaches. 7) Factorial calculation. 8) Prime number checking. Each section includes a brief description and C code to implement the given problem.

Uploaded by

Anand Kumar
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
100% found this document useful (1 vote)
94 views

Write A Program For:: #Include

The document contains C code implementations for several common programming problems: 1) Palindrome checking for strings and numbers. 2) String reversal. 3) Sum and average of numbers. 4) Prime number checking. 5) Armstrong number checking. 6) Fibonacci series using iterative and recursive approaches. 7) Factorial calculation. 8) Prime number checking. Each section includes a brief description and C code to implement the given problem.

Uploaded by

Anand Kumar
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/ 5

Wipro Placement Program

Write a Program for :

1.palindrome for string and number

2.String Reverse

3.Sum,Average of all the number

4.Prime no

5.Armstrong no

6.fibonacci

7.factorial

8.prime number,

1.Palindrome for string

#include <stdio.h>

#include <string.h>

main()
{
char a[100], b[100];

printf("Enter the string to check if it is a palindrome\n");


gets(a);

strcpy(b,a);
strrev(b);

if( strcmp(a,b) == 0 )
printf("Entered string is a palindrome.\n");
else
printf("Entered string is not a palindrome.\n");
return 0;
}

2.Palindrome number in c

#include <stdio.h>

main()
{
int n, reverse = 0, temp;

printf("Enter a number to check if it is a palindrome or not\n");


scanf("%d",&n);

temp = n;

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

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

return 0;
}

3.Reverse a string using C programming

#include<stdio.h>
#include<string.h>

main()
{
char arr[100];

printf("Enter a string to reverse\n");


gets(arr);

strrev(arr);

printf("Reverse of entered string is \n%s\n",arr);


return 0;
}

4./* Fibonacci Series c language */

#include<stdio.h>

main()
{
int n, first = 0, second = 1, next, c;

printf("Enter the number of terms\n");


scanf("%d",&n);

printf("First %d terms of Fibonacci series are :-\n",n);

for ( c = 0 ; c < n ; c++ )


{
if ( c <= 1 )
next = c;
else
{
next = first + second;
first = second;
second = next;
}
printf("%d\n",next);
}

return 0;
}

5.Fibonacci series program in c using recursion

#include<stdio.h>

int Fibonacci(int);

main()
{
int n, i = 0, c;
scanf("%d",&n);

printf("Fibonacci series\n");

for ( c = 1 ; c <= n ; c++ )


{
printf("%d\n", Fibonacci(i));
i++;
}

return 0;
}

int Fibonacci(int n)
{
if ( n == 0 )
return 0;
else if ( n == 1 )
return 1;
else
return ( Fibonacci(n-1) + Fibonacci(n-2) );
}

6.Adding numbers in c using function

#include<stdio.h>

long addition(long, long);

main()
{
long first, second, sum;

scanf("%ld%ld", &first, &second);

sum = addition(first, second);

printf("%ld\n", sum);

return 0;
}

long addition(long a, long b)


{
long result;

result = a + b;
return result;
}

You might also like