Posts

c patterns level 2

Image
/******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> int main() {     int i,j,k=1,l=9,tmp;     for(i=1,k=1;i<=10;i++,k=k+2,l--){           tmp=l;         for(j=1;j<=19;j++){                     if(j<=k){                        if(j<=i) {                ++tmp;                ...

patterns programs in c

Image
/******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> int main() {     int i,j,k,l;     for(i=1;i<=9;i++){               for(j=1;j<=5;j++){                      if(i<6){if(j<6-i) printf("  ");             else printf("* ");         }         else{             if(j<=i-5) printf("  ");       ...

task : debug the prime number logic

#include <stdio.h> #include <math.h> void main(){   int x,n=0,i; scanf("%d",&x); for(i=0;i<(int)sqrt(x);i++){     if(x%i==0){     n=1;     break;     }     } if(n==1) printf("not"); else printf("PRIME"); }

reverse of given string worlds c program -asr

Image
#include <stdio.h> void main(){         int i=0,len,num=0,a[10],j,f,l;     char s[100];                 while(1){         s[i]=getchar();         if(s[i]=='\n'){                 len=i;           //get chatacters                 s[i]=' ';        //set last character as space             break;   //break if enter pressed         }                 i++;     }         for(i=0;i<len;i++){     if(s[i]==' '){         a[num]=i+1;     //detect the positions where space is present         num++;     }     }  ...

kite patterns in c

Image
/******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> int main() {     int i,j,k;     for(i=1;i<=6;i++){             for(j=1;j<=5;j++){         if(i==1||i==5) {                        if(j==3) printf("*");             else printf(" ");                     }            if(i==2||i==4||i==6) {...

beautiful stars pattern based on inputted number-asr

Image
/******************************************************************************                             Online C Compiler.                 Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> #include <stdlib.h> int main() {     char a[20],n[10]; int num[10],x=0; int i=0,big=1,j; while(1){ a[i]=getchar(); n[0]=a[i]; //assignt into n[0] otherwise will err...coz index start from 0 num[x]=atoi(n);    if(a[i]=='\n'){     break;    }  i++; x++; } big=num[0]; for(i=1;i<x;i++){       if(big<num[i])   {         big=num[i];      //finding big number from inp...

aaabb to32 ,aabbb to a2b3 convert in c-asr

Image
/******************************************************************************     Online C Compiler. Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> int main() {   char s[10],c[10];   int i=1,j,tmp[10];   int p[10];   static int x,num=0;   s[0]='*';   c[0]='*';   tmp[0]=0;  printf("\nEnter a string\n");  while(1){     s[i]=getchar(); //reads single characters until enter pressed      if(s[i]==s[i-1])    //checks the previous character matched or not      { x++; tmp[num]=x; //increment x as much as character matches the previous characters insert into tmp      }      else{ x=1...