Skip to main content

Posts

Showing posts from April, 2013

wap to print the following pattern.

wap to print the following pattern in c----     #include<stdio.h> void main() { int i,j,k,f=1; for(i=65;i<=71;i++) printf("%c",i); for(i=70;i>=65;i--) printf("%c",i); printf("\n"); for(i=1;i<=6;i++) {   {    for(j=65;j<=71-i;j++)    printf("%c",j);    }      {       for(k=1;k<=f;k++)        printf(" ");        f=f+2;       for(k=71-i;k>=65;k--)       printf("%c",k);      }  printf("\n"); } } NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h   header file in the beginning  and getch()   a the  last.

wap to input a five digit number and add 1 to each digit such that the output is as follows ..e.g 12569...so the output should be..23670..... this is to be done without using any loop....

#include<stdio.h> void main() { long int num,a,b,c,d,e,f,g,h,eureka; printf("enter the five digit number"); scanf("%d",&num); a=num/10000; b=num%10000; c=b/1000; d=b%1000; e=d/100; f=d%100; g=f/10; h=f%10; a=((a+1)%10)*10000; c=((c+1)%10)*1000; e=((e+1)%10)*100; g=((g+1)%10)*10; h=((h+1)%10)*1; eureka=a+c+e+g+h; printf("the increased no. is %d",eureka); }

write a function factorial to find the factorial of a number and use this function to solve the following series:::: y=(1!)+(1!+2!)+(1!+2!+3!)+............n terms

the following program  came in my sessional. and i wrote it   and is in front of u ,  check it out.::::::::::: #include<stdio.h> #include<conio.h> int fact(int i); int main() { int sum=0 ,i,n,e; printf("enter the no. til u want the series"); scanf("%d",&n); for(i=1;i<=n;i++) { e=fact(i); sum=e+sum; } printf("the sum of the series is  %d",sum); } int fact(int i) { int t,j,a=1,d=0; for(t=1;t<=i;t++) { for(j=1;j<=t;j++) { a=a*j; } d=d+a; a=1; printf("%d \n",d); } return(d); }