Posts

Showing posts from July, 2021

C graphics Concentric Circle

 Concentric Circle * Graphics program of circle * #include<stdio.h> #include<conio.h> #include<graphics.h> void main() { int gdriver=DETECT,gmode; int x,y; initgraph(&gdriver, &gmode,"C://TURBOC3//bgi"); /* x=getmaxx()/2; y=getmaxy()/2; setcolor(WHITE); outtextxy(140,70,"Concentric Circle"); setcolor(RED); circle(x,y,30); setcolor(GREEN); circle(x,y,50); setcolor(YELLOW); circle(x,y,70); setcolor(BLUE); circle(x,y,90); * Some other function in Graphics in C * circle(220,350,20); line(50,50,100,100); arc(50,50,30,180,30); setcolor(BLUE); outtext("Program is My name"); setcolor(BLUE); floodfill(200,300,GREEN);*/ setfillstyle(HATCH_FILL,GREEN); bar3d(200,300,450,200,50,20); settextstyle(1,HORIZ_DIR,15); outtext("ABCD"); rectangle(100,400,400,300);getch(); closegraph(); getch(); }

DMA malloc in Pointer.

  DMA is a Dynamic Memory Memory Allocation using to declare memory address. DMA have four function ::: 1. malloc() 2. calloc() 3. realloc() 4. free() * Malloc Example code * #include<bits/stdc++.h> #include<stdio.h> #include<stdlib.h> using namespace std; int main() { int i,n,min,max,j; // for allocate memory .... cout<<"Enter the number of items\n"; cin>>n; int *ptr; // for pointer....... ptr=(int *) malloc(n* sizeof(int)); // allocation of the memory n*4 bytes of int  if(ptr==NULL)  { cout<<"Memory not allocated\n"; exit(0); } else { cout<<"Memory successfully allocatedd\n"; for(int i=0;i<n;++i){ scanf("%d",(ptr+i)); } } cout<<"The elements of pointer are \n"; for(int i=0;i<n;++i){ printf("%d\t",ptr[i]); } max=ptr[0]; for(i=0;i<n;++i){ if(max<ptr[i]){ max=ptr[i]; }     } cout<<max<...

STRLEN Function in C

 Program for own  Strlen  *Write Own Strlen Function * #include<stdio.h> #include<string.h> unsigned int astrlen(char str[]){ int i=0; while(str[i]!='\0') i++; return i; } int main() { char str[10]; gets(str); printf("The length of string is %d",astrlen(str));n }

C++ Program to find x^n using recursion.

 Recursion program * Recursion x^n program* #include<bits/stdc++.h> #include<stdio.h> using namespace std; int power(int x, int n) { if(n!=0){ return (x* power(x,n-1)); } else  return 1; } int main() { int a,pow; cout<<"Enter the base and exponenent item\n"; cin>>a>>pow; cout<<"The power of the "<<a<< "^"<<pow<<" is "<<power(a,pow); return 0; }

C Program to Sort Id, Name, Address of Student using structure.

 Structure Programm *Program with POINTER* #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<string.h> struct student{ int id; char name[20]; char address[20]; }s1[10],*p; int main() { int i,j,temp,n; printf("Enter the n items \n"); scanf("%d",&n); char tempchar[50],tempchar1[50]; printf("Enter the id name and address of 5 students\n"); for(p=s1;p<s1+n;++p) { scanf("%d %s %s",&p->id,p->name,p->address); } p=s1; for(i=0;i<n;++i){ for(j=i+1;j<n;++j){ if(strcmp((p+i)->name,(p+j)->name)<0) { strcpy(tempchar,(p+i)->name); strcpy((p+i)->name,(p+j)->name); strcpy((p+j)->name,tempchar); strcpy(tempchar1,(p+i)->address); strcpy((p+i)->address,(p+j)->address); strcpy((p+j)->address,tempchar1);         temp=(p+i)->id;         (p+i)->id=(p+j)->id;   ...

C ++

Image
C++ 14 !! We use Following code to Build c++14 Build with System in Sublime Text 3 : { "cmd" : [ "g++.exe" , "-std=c++14" , "${file}" , "-o" , "${file_base_name}.exe" , "&&" , "${file_base_name}.exe<inputf.in>outputf.in" ] , "selector" : "source.cpp" , "shell" : true , "working_dir" : "$file_path" } STEP : 1 Open New build System as mention in above picture... STEP : 2 Copy above code and Save it as name = c++14 This file name is save under JSON(******) package.