Sunday, August 25, 2019

A smart calculator in c..


#include <stdio.h>
main()
{
float a,b;
char c;
int ch,i=0;

start:
printf("give exp.\n {in form of a operator b}\n");
scanf("%f%c%f",&a,&c,&b);
i=i+1;
if(i>3)
{

printf("reply...if u like it\n");
goto body;

}
body: switch(c)
{case '+':
printf("%f is addi.\n",a+b);break;
case '-':
printf("%f is sub.\n",a-b);break;
case '*':
printf("%f is multi.\n",a*b);
break;
case'/':
printf("%f is div.\n",a/b);break;
case'=':
printf("enter in form of a operator b");break;
default:printf("invalid,try again\n");
        goto start;
}
printf("enter 1 for using again\n or any other greater int. to quit\n");
scanf("%d",&ch);
if(ch>1)
return 0;
else
goto start;
    }

Implement stsStr Leetcode solution

  28.   Implement strStr() Easy Implement  strStr() . Given two strings  needle  and  haystack , return the index of the first occurrence of...