Monday, 30 March 2015

c program for conversion of uppercase to lower case to print ASCII value

 write a c program to convert of uppercase to lower case to print ASCII value
/*conversion of uppercase to lower case ASCII value*/
/*author:sai date:31-3-2015*/

#include<stdio.h>
main()
{
   char ch;
   printf("enter the charter in upper case\n");
   scanf("%c", &ch);
   printf("ASCII value%d\n", ch-32);
}



c program to check whether the given number is even or odd using goto statement

write a c program to check whether the given number is even or odd  using goto statement

/* c program to check whether the given  number is even or odd  using goto statement */

/* author: sai      date:30-3-2015 */

#include<stdio.h>
int main()
{
 int n;
 printf("\n enter number to check even or odd");
 scanf("%d",&n);
 if(n%2==0)
 goto even;
 else
 goto odd;
 even:printf("%d is even number\n",n);
 return;
 odd: printf("%d is odd number\n",n);
}



c program to print an integer that user entered using keyboard

write a c program to print an integer that user entered using keyboard

/* c program to print an integer that user entered using keyboard */

/* author: sai date:27-3-2015 */

#include

int main()
{
int n;

printf("Enter an integer\n");
scanf("%d", &n);

printf("Integer that you have entered is %d\n", n);

return 0;
}



c program to addition of two numbers

write a c program to addition of two numbers

/*  c program to addition of two numbers */

/* author:sai       date:27-3-2015 */

#include

int main()
{
int a,b,c;

printf("Enter two numbers for addition\n");
scanf("%d%d",&a,&b);

c = a + b;

printf("Sum of two numbers is = %d\n",c);

return 0;
}

Friday, 27 March 2015

Shell Script to Find Factorial of a Number

3)write a Shell Script to Find Factorial of a Number?
clear
echo "enter number"
read fact

ans=1
counter=0
while [ $fact -ne $counter ]
do
counter=`expr $counter + 1`
ans=`expr $ans \* $counter`
done
echo "Total of factorial is $ans"

Write a shell program to check whether a given string is palindrome or not


2) Write a shell program to check whether a given number is palindrome or not?
clear
echo "Enter the number you want?"
read num
m=$num
rev=0
while [ $num -gt 0 ]
do
r=`expr $num % 10`
rev=`expr $rev \* 10 + $r`
num=`expr $num / 10`
done
if [ $m = $rev ]
then
echo " $m is Palindrome"
else
echo " $m is not Palindrome"
fi


Write a shell script program to print the fibonacci series

1) Write a shell script program to print the fibonacci series


clear
echo "How many number of terms to be generated ?"
read n
x=0
y=1
i=2
echo "Fibonacci Series up to $n terms :"
echo "$x"
echo "$y"
while [ $i -lt $n ]
do
i=`expr $i + 1 `
z=`expr $x + $y `
echo "$z"
x=$y
y=$z
done