Skip to main content

Posts

Showing posts with the label C programs

Number Guessing game In C Programming Language

Guess the Number Number Guessing Game in C language. /* Program to make a number guessing game */ #include<stdio.h> main() {  int i,num=51,flag=1,guess,count=0;  printf("Guess the number\n");  scanf("%d",&guess); do  {   if(num==guess)   {    flag=0;   }   else if(guess<num)   {    flag=1;    printf("Your guess is lower than the number\n");    count++;   }   else   {     flag=1;    printf("Your guess is greater than the number\n");    count++;   }   if(flag==1)   {     printf("Sorry! Please guess it again\n");    scanf("%d",&guess);   }  } while(flag);  printf("Congrats! You guessed the number %d\n",num);  printf("Number of trails: %d\n",count); } Watch the video :  https://youtu.be/i6Xlvvm8rd4

Program to find the ASCII value in C langauge

C program to find ASCII value #include<stdio.h> #include<string.h> main() {      int i,temp,x,y=1,binary=0;      char str[1000];      printf("\n\n\t\t\t ENTER THE SENTENCE : ");      gets(str);      i=0;      printf("\n\n\n\t\t\t ENCRYPTED ASCII CODE : "); while(str[i]!='\0')      {      printf(" %d",str[i]);      i++;      }      return 0; } Video link : https://youtu.be/2SfBV_nbehA

How to create Loading Animation in C language

 Make loading animation Using C programming language #include<stdio.h> #include<conio.h> #include<graphics.h> // header file for graphics functions #include<dos.h> int main() {        int gd=DETECT;         int gm,i,j,k,midx,midy; //variable to be used      initgraph(&gd,&gm,"C:\\Turboc3\\BGI"); //initializing and setting the path of graphics file      midx=getmaxx()/2; //getting center of x-axis      midy=getmaxy()/2; //getting center of y-axis for(j=1;j<10;j++)      {      for(i=2,k=340;i<340,k>2;i=i+10,k=k-10)      {      setcolor(j);      arc(midx,midy,0+i,40+i,40); // creating the upper arc      setcolor(j+1);      arc(midx,midy,50+k,80+k,40); // creating the lower arc  ...

Corona virus guidelines chart program in C language

C Program to create Amazing  Coronavirus guidelines Chart #include<graphics.h> #include<dos.h> #include<conio.h> void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"C:\\Turboc3\\BGI"); int x,y,i; x=getmaxx()/2; y=getmaxy()/2; setbkcolor(0); for(i=0;i<20;i++){ //-------- rectangle ----------------- setcolor(i+2); rectangle(20,20,x*2-15,y*2-150); delay(600); rectangle(15,15,x*2-10,y*2-145); delay(400); //----------- heading ------------ setcolor(i+1); settextstyle(7,HORIZ_DIR,2); outtextxy(x-170,45, "-: CORONA VIRUS GUIDELINES :-"); line(x-180,73,x+200,73); delay(500); // ---------- points section ------------ setcolor(i); settextstyle(1,HORIZ_DIR,1); outtextxy(35,90,"1. STAY HOME. "); outtextxy(35,120,"2. REGULARLY WASH YOUR HANDS. "); outtextxy(35,150,"3. MAINTAIN SOCIAL DISTANCE AND AVOID PUBLIC GATHERING . "); outtextxy(35,180,"4. AVOID TOUCHING EYES,NOSE AND M...

Toss game program in C language

CODE FOR TOSS GAME  #include<stdio.h> #include<time.h> #include<stdlib.h>  // its a standard library header file main() { int number,guess; srand(time(NULL)); // this is the function to generate a random number between 0 and 1.. number=rand()%2;  // this is the actual operation for 1 and 0.. // if no. is even it gives 0 and 1 otherwise.. printf("\n \t ENTER 1 FOR TAIL AND 0 FOR HEAD : "); scanf("%d",&guess); printf(" \n THE RESULT OF THE TOSS IS :  "); // testing the condition for head or tail... if(number==0) printf(" head  \n !!!"); else printf("tail \n"); printf(" You guessed "); if(guess==0) printf("Head\n"); else printf("Tail \n"); if(number ==guess) printf(" hurray ! you won the toss !!!"); else printf(" bad luck !!\n Better luck next time : : "); } ...

Program to create pyramid in C language

C PROGRAM TO MAKE A RIGHT POINTED PYRAMID #include<stdio.h> main() { int i,j,k,row,count,temp; printf("\t ENTER THE NUMBER OF THE ROWS : "); scanf("%d",&row); for(i=1;i<=row;i++) { for(j=1;j<=i;j++) { printf("* "); } printf("\n"); } for(i=row-1;i>=1;i--) { for(j=i;j>=1;j--) { printf("* "); } printf("\n"); } } click here  for my youtube channel

Program to create X pattern in C language

C PROGRAM TO CREATE X PATTERN #include<stdio.h> main() {      int len,i,j,row;      printf("\n ENTER THE NUMBER OF THE ROWS : ");      scanf("%d",&row);      for(i=1;i<=row;i++)  // for loop for the rows ..      {           for(j=0;j<row;j++)   //for loop for the columns...           {           if(i==j||i+j==row -1) // this is the main logic for the required pattern..           {                printf("*");           }           else{                printf(" ");   // white space where it should be blank..          }  ...

Program to create a Square pattern

C program to generate a square in C language #include<stdio.h> main() { int i,j,n; printf("\t enter size of square to generate a square :  "); scanf("%d",&n); for(i=1;i<=n;i++)  // for row { for(j=1;j<=n;j++)  // for column  { if(i==1||i==n) // to fill the first and last line.. printf("S ");   //print  s in first and last line .. else{                // condition for remianing lines.. if(j==1||j==n)    // condition for first and last column printf("S ",j);  // prints the s in first and last column .. else     printf("  ");  // leave space for remaining rows .. } } printf("\n"); // print new line after every row... } } Watch video : https://youtu.be/hKxYeZ5To9Q