HERE YOU WILL GET ANSWER OF YOUR QUESTIONS AND NEW THINGS THAT WILL INNOVATE YOUR MIND ..BASICALLY IN PYTHON AND C
Sunday, November 3, 2019
Thursday, October 24, 2019
Hacker rank-for loop
#include <stdio.h>
main()
{ int i,a,b;
scanf("%d",&a);
scanf("%d",&b);
for(i=a;i<=b;i++)
{ if(i>9)
{ if(i%2==0)
printf("even\n");
else printf("odd\n");
}
else switch(i)
{ case 1:printf("one\n");break;
case 2:printf("two\n");break;
case 3:printf("three\n");break;
case 4:printf("four\n");break;
case 5:printf("five\n");break;
case 6:printf("six\n");break;
case 7:printf("seven\n");break;
case 8:printf("eight\n");break;
case 9:printf("nine \n");break;
}
}
}
main()
{ int i,a,b;
scanf("%d",&a);
scanf("%d",&b);
for(i=a;i<=b;i++)
{ if(i>9)
{ if(i%2==0)
printf("even\n");
else printf("odd\n");
}
else switch(i)
{ case 1:printf("one\n");break;
case 2:printf("two\n");break;
case 3:printf("three\n");break;
case 4:printf("four\n");break;
case 5:printf("five\n");break;
case 6:printf("six\n");break;
case 7:printf("seven\n");break;
case 8:printf("eight\n");break;
case 9:printf("nine \n");break;
}
}
}
Hackerrank --Printing each word of an string in new line in c
#include <stdio.h>
int main()
{char sen[1000];
int i=0;
gets(sen);
while(sen[i]!='\0')
{ if(sen[i]==' ')
printf("\n");
else printf("%c",sen[i]);
i++;
}
return 0;
}
int main()
{char sen[1000];
int i=0;
gets(sen);
while(sen[i]!='\0')
{ if(sen[i]==' ')
printf("\n");
else printf("%c",sen[i]);
i++;
}
return 0;
}
Pattern in c using loop(hackerrank medium level question)
Hello guys this is code for hakerrank pattrn question ...30 points
#include <stdio.h>
int main()
{
int n,i,j;
scanf("%d",&n);
for(i=n;i>0;i--)
{ for(j=n;j>0;j--)
{ if(i==j)
printf("%d",i);
else if(j<i)
printf("%d",i);
else printf("%d",j);
}
for(j=2;j<=n;j++)
{ if(i==j)
printf("%d",i);
else if(j<i)
printf("%d",i);
else printf("%d",j);
}
printf("\n");
}
for(i=2;i<=n;i++)
{ for(j=n;j>=1;j--)
{ if(i==j)
printf("%d",i);
else if(j<i)
printf("%d",i);
else printf("%d",j);
}
for(j=2;j<=n;j++)
{ if(i==j)
printf("%d",i);
else if(j<i)
printf("%d",i);
else printf("%d",j);
}
printf("\n");
}
return 0;
}
Subscribe to:
Posts (Atom)
Implement stsStr Leetcode solution
28. Implement strStr() Easy Implement strStr() . Given two strings needle and haystack , return the index of the first occurrence of...
-
php apache setup on android with Termux (without root) ***downloading and intalling termux go to given link and choose a suitable version of...
-
38. Count and Say Medium The count-and-say sequence is a sequence of digit strings defined by the recursive formula: countAndSay(1) = ...