Popular posts from this blog
print diamond of alphabets Pattern Using C
//pattern #include<stdio.h> int main() { int h,i,j; printf("Enter the height"); scanf("%d",&h); for(i=1;i<=h;i++) { for(j=1;j<20-i;j++) printf(" "); for(j=1;j<=i;j++) printf("%c ",64+j); for(j=j-2;j>=1;j--) printf("%c ",64+j); printf("\n"); } for(i=h-1;i>=1;i--) { for(j=1;j<20-i;j++) printf(" "); for(j=1;j<=i;j++) printf("%c ",64+j); for(j=j-2;j>=1;j--) printf("%c ",64+j); printf("\n"); } }
use of malloc() function ....
#include<stdio.h> #include<conio.h> int main() { int *ptr,n,i; printf("Enter the number of elements : "); scanf("%d",&n); ptr=(int *)malloc(n*sizeof(int)); printf("Enter the elements : "); for(i=0;i<n;i++) scanf("%d",(ptr+i)); printf("Elements are : "); for(i=0;i<n;i++) printf("%d",*(ptr+i)); system("pause"); } input: Enter the number of elements : 4 Enter the elements : 2 3 4 ouput : Elements are : 2 3 4

Comments
Post a Comment