karanvirghotra / urban-winner

0 stars 0 forks source link

ITPS class #1

Open karanvirghotra opened 1 year ago

karanvirghotra commented 1 year ago

/**

                        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

include

include

int main() { int a,b,c,d,k ; char f; printf("Enter your choice\n"); printf("1.Find largest number among two numbers\n"); printf("2.Want to perform bitwise opertors\n"); printf("3. Find square root of number\n"); printf("4. find a to the power b\n"); printf("press 5 for exit\n"); scanf("%d",&k); switch(k) { karan: case 1: { printf("\nEnter a and b\n"); scanf("%d",&a); scanf("%d",&b); c=(a<b?b:a); printf("Your largest number is %d\n",c); break;

}
case 2:
{
    printf("\nEnter a and b\n");
    scanf("%d",&a);
    scanf("%d",&b);
    printf(" logical OR operation of %d %d %d\n is :",a,b,a|b);
    printf(" logical And operation of %d %d %d\n is :",a,b,a&b);
    printf("XOR = %d\n", a^b);
    printf("NOT = %d\n", a =~a);  
    printf("b<<1 = %d\n", b<<1); 
    printf("b>>1 = %d\n", b>>1); 
    break;

}
case 3:
{
    printf("\nEnter a and b\n");
    scanf("%d",&a);
    scanf("%d",&b);
    c=sqrt(a);
    d=sqrt(b);
    printf("roots of two numbers a and b is %d\n , %d",c,d);

}
case 4:
{
    printf("\nEnter a and b\n");
    scanf("%d",&a);
    scanf("%d",&b);
    c=pow(a,b);
    printf("a to the power b is %d",c);

}
case 5:
{
    exit(0);
}
default:

scanf("%c",&f);
    printf("Enter yes or no \n");
    fflush(stdin);
    scanf("%d",&c);
    int y,n;
    char yes,no,h;

    if(f==y)
    {
        goto karan;
    }
    else
    {
        exit (0);
    }

}

}