1. #include <stdio.h>
int main ()
{
int a,b=10,c=20;
printf("value of b before swap : %d\n",b);
printf("value of c before swap : %d\n",c);
a=b;
b=c;
c=a;
printf("value of b after swap : %d\n",b);
printf("value of c after swap : %d\n",c);
return 0;
}
2. #include <stdio.h>
int main ()
{
int x;
printf ("Enter the number : ");
scanf ("%d",&x);
if (x<0)
printf ("Zero");
else if (x==0)
printf ("Negative");
else
printf ("positive");
return 0;
}
3. #include <stdio.h>
int main ()
{
int x;
printf ("Enter the year : ");
scanf ("%d",&x);
if (x%400==0)
printf ("Leap Year");
else if (x%100==0)
printf ("Not a Leap Year");
else if (x%4==0)
printf ("Leat Year");
else
printf ("Not a Leap Year");
return 0;
}
4. #include <stdio.h>
int main ()
{
int y,x;
printf("Enter 1st terminal : ");
scanf("%d",&x);
printf("Enter 2st terminal : ");
scanf("%d",&y);
if (x%y==0)
printf("first is evenly divisible by the second");
else
printf("first is not evenly divisible by the second");
return 0;
}
int main ()
{
int y,x;
printf("Enter 1st value : ");
scanf("%d",&x);
printf("Enter 2st value : ");
scanf("%d",&y);
if (y==0)
printf("Can't do division by 0");
else
printf("%.3f",(float)x/y);
return 0;
}
int main ()
{
int y,x;
printf("Enter the value : ");
scanf("%d",&x);
if (x>1000)
printf("Enter the number less than 1000");
else
for ( y=100; y!=0; )
{
if (x/y==0)
printf("Zero ");
else if (x/y==1)
printf("One ");
else if (x/y==2)
printf("Two ");
else if (x/y==3)
printf("Three ");
else if (x/y==4)
printf("Four ");
else if (x/y==5)
printf("Five ");
else if (x/y==6)
printf("Six ");
else if (x/y==7)
printf("Seven ");
else if (x/y==8)
printf("Eight ");
else
printf("Nine ");
x=x%y;
y=y/10;
}
return 0;
}
7. #include <stdio.h>
int main()
{
float Physics, Chemistry, Biology, Mathematics,
Computer,percentage;
char grade;
printf("Enter the Physics marks
: ");
scanf("%f",&Physics);
printf("Enter the Biology marks
: ");
scanf("%f",&Biology);
printf("Enter the Chemistry
marks : ");
scanf("%f",&Chemistry);
printf("Enter the Mathematics
marks : ");
scanf("%f",&Mathematics);
printf("Enter the Computer
marks : ");
scanf("%f",&Computer);
percentage=(Physics+Chemistry+Biology+Mathematics+Computer)/5;
if (percentage >= 90)
grade='A';
else if (percentage >= 80)
grade='B';
else if (percentage >= 70)
grade='C';
else if (percentage >= 60)
grade='D';
else if (percentage >= 40)
grade='E';
else
grade='F';
printf("%c",grade);
return 0;
}
0 Comments
Post a Comment