Archive for the ‘Lab 6’ Category

#include <stdio.h>
int  main()
{
int num;
printf("Enter your mark: ");
scanf("%d",&num);
if(num >80&&num<=100)
		{
printf(" You got A grade"); 
}
else if ( num >60&&num<=80)
		{ 
printf(" You got B grade");
}
else if ( num >40&&num<=60)
		{
printf(" You got C grade");
}

else if ( num < 40)
		{
printf(" You Failed in this exam");
}
return 0;
}
Advertisements
#include<stdio.h>
int main()
{
	int year;
	printf("Enter Year:");
	scanf("%d",&year);
 if(year%400 ==0 || (year%100 != 0 && year%4 == 0))
    {
        printf(" %d is a Leap year",year);
    }
    else
    {
        printf("%d is not a Leap year",year);
    }
	return 0;
}
\\using three variable\\
#include <stdio.h>
int main()
{
   int x, y, temp;
 
   printf("Enter Two Numbers\n");
   scanf("%d%d", &x, &y);
 
   printf("Before Swapping\nx = %d\ny = %d\n",x,y);
 
   temp = x;
   x = y;
   y = temp;
 
   printf("After Swapping\nx = %d\ny = %d\n",x,y);
 
   return 0;
}
#include<stdio.h>
int main()
{
int x,y,z;
printf("Enter values of x, y and z :\n ");
scanf("%d%d%d",&x,&y,&z);
if(x>=y && x>=z)
printf("\nx=%d is greatest",x);
else if(y>=z)
printf("\ny=%d is greatest",y);
else
printf("\nz=%d is greatest",z);
return 0;
}
#include<stdio.h>
int main()
{
int maths,physics,chemistry,total,total1;
printf("Enter Marks:\n");
scanf("%d%d%d",&maths,&physics,&chemistry);
printf("Maths=%d\nPhysics=%d\nChemistry=%d",maths,physics,chemistry);
total=maths+physics+chemistry;
total1=maths+physics;
if(maths>=60&&physics>=50&&chemistry>=40)
{
if(total>=200||total1>=150)
{
printf("\nYou Are Eligible");
}
}
else
printf("\nYou Are Not Eligible");

return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,d,e,f,ch;
printf("Enter 1st no\n");
scanf("%d",&a);
printf("Enter 2nd no\n");
scanf("%d",&b);
printf("Enter choice 1.add 2.sub 3.mul 4.div\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
c=a+b;
printf("%d",c);
break;
case 2:
d=a-b;
printf("%d",d);
break;
case 3:
e=a*b;
printf("%d",e);
break;
case 4:
f=a/b;
printf("%d",f);
break;
}
return 0;
}
#include<stdio.h>
int main()
{
	int n;
	printf ("Enter a number: ");
scanf ("%d",n);
	if(n%2==0)
	{
		printf("EVEN NUMBER");
	}
		else
	{
			printf("ODD NUMBER");
		}
	return 0;
}
#include<stdio.h>
int main()
{
int n;
printf ("Enter a number: ");
scanf ("%d",&n);
(n%2==0 ? printf("Even NUMBER"):printf ("ODD NUMBER"));
	return 0;
}